2
* Copyright(C) 2010 Neil Jagdish Patel
3
* Copyright(C) 2010 Canonical Ltd.
5
* This library is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU Lesser General Public License
7
* version 3.0 as published by the Free Software Foundation.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Lesser General Public License version 3.0 for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library. If not, see
16
* <http://www.gnu.org/licenses/>.
18
* Authored by Neil Jagdish Patel <neil.patel@canonical.com>
19
* Authored by Ken VaDine <ken.vandine@canonical.com>
23
[DBus (name = "com.Gwibber.Messages")]
24
private interface MessagesInterface : Object {
25
public signal void Message (string change, string data);
26
public abstract string Get (string mid) throws GLib.IOError;
31
public class Messages : Object
33
private const string messages_name = "com.Gwibber.Messages";
34
private const string messages_path = "/com/gwibber/Messages";
36
private MessagesInterface messages_service;
37
private Gwibber.Utils utils;
40
Messages::is_available:
41
@arg0: The current state
43
Emitted when com.Gwibber.Messages availability state changes
45
public signal void is_available(bool is_up);
52
Emitted when there is a new message
54
public signal void message(string change, string data);
60
this.messages_service = Bus.get_proxy_sync(BusType.SESSION,
63
this.utils = new Gwibber.Utils();
64
this.utils.setup(this.messages_name);
65
this.utils.available.connect(this.messages_available);
66
messages_service.Message.connect((change, data) => {
67
this.on_new_message (change, data);
70
catch (GLib.IOError e)
72
warning ("Unable to get Gwibber Messages "+e.message);
78
* com.Gwibber.Messages
81
public GLib.Array stream(string stream, string account, int time, string transient, string recipient, string orderby, string order, int limit)
85
return messages_service.Stream(stream, account, time, transient, recipient, orderby, order, limit);
87
catch (GLib.IOError e)
96
public string get_message (string mid)
100
return messages_service.Get(mid);
102
catch (GLib.IOError e)
110
public void on_new_message(string change, string data)
112
this.message(change, data);
115
private void messages_available(bool is_up)
117
this.is_available(is_up);