summaryrefslogtreecommitdiff
path: root/libmissioncontrol/mission-control.h
blob: 9ac9716870d54c929e6cba5746f120e3288fc133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */
/*
 * This file is part of mission-control
 *
 * Copyright (C) 2007 Nokia Corporation. 
 *
 * Contact: Naba Kumar  <naba.kumar@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef MISSION_CONTROL_LIB_H
#define MISSION_CONTROL_LIB_H

#ifndef DBUS_API_SUBJECT_TO_CHANGE
#define DBUS_API_SUBJECT_TO_CHANGE
#endif

#include "dbus/dbus-glib.h"
#include "dbus/dbus-glib-lowlevel.h"
#include "dbus/dbus.h"
#include <libtelepathy/tp-constants.h>
#include <libtelepathy/tp-conn.h>
#include <libtelepathy/tp-chan.h>
#include <sys/types.h>
#include <unistd.h>

#define MISSION_CONTROL_SERVICE "org.freedesktop.Telepathy.MissionControl"
#define MISSION_CONTROL_IFACE "org.freedesktop.Telepathy.MissionControl"
#define MISSION_CONTROL_PATH "/org/freedesktop/Telepathy/MissionControl"

#define MISSIONCONTROL_TYPE       (mission_control_get_type ())

#define MISSIONCONTROL(obj)       (G_TYPE_CHECK_INSTANCE_CAST \
				   ((obj), MISSIONCONTROL_TYPE, \
				    MissionControl))

#define MISSIONCONTROL_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST \
					   ((klass), MISSIONCONTROL_TYPE, \
					    MissionControlClass))

#define IS_MISSIONCONTROL(obj)    (G_TYPE_CHECK_INSTANCE_TYPE \
				   ((obj), MISSIONCONTROL_TYPE))

#define IS_MISSIONCONTROL_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE \
					   ((klass), MISSIONCONTROL_TYPE))

#define MISSIONCONTROL_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS \
					   ((obj), MISSIONCONTROL_TYPE, \
					    MissionControlClass))

#define MC_ERROR (mission_control_error_quark())

typedef struct _missioncontrol MissionControl;
typedef struct _missioncontrolclass MissionControlClass;

typedef enum {
    MC_DISCONNECTED_ERROR,
    MC_INVALID_HANDLE_ERROR,
    MC_NO_MATCHING_CONNECTION_ERROR,
    MC_INVALID_ACCOUNT_ERROR, 
    MC_PRESENCE_FAILURE_ERROR,
    MC_NO_ACCOUNTS_ERROR,
    MC_NETWORK_ERROR,
    MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR,
    MC_LOWMEM_ERROR,
    MC_CHANNEL_REQUEST_GENERIC_ERROR,
    MC_CHANNEL_BANNED_ERROR,
    MC_CHANNEL_FULL_ERROR,
    MC_CHANNEL_INVITE_ONLY_ERROR,
    MC_LAST_ERROR /*< skip >*/
} MCError;

typedef enum {
    MC_PRESENCE_UNSET,
    MC_PRESENCE_OFFLINE,
    MC_PRESENCE_AVAILABLE,
    MC_PRESENCE_AWAY,
    MC_PRESENCE_EXTENDED_AWAY,
    MC_PRESENCE_HIDDEN,
    MC_PRESENCE_DO_NOT_DISTURB,
    LAST_MC_PRESENCE /*< skip >*/
} McPresence;

typedef enum {
    MC_STATUS_DISCONNECTED,
    MC_STATUS_CONNECTING,
    MC_STATUS_CONNECTED,
} McStatus;

typedef enum {
	MC_FILTER_PRIORITY_CRITICAL = 0,
	MC_FILTER_PRIORITY_SYSTEM = 1000,
	MC_FILTER_PRIORITY_NOTICE = 2000,
	MC_FILTER_PRIORITY_DIALOG = 3000,
	MC_FILTER_PRIORITY_MONITOR = 4000
} McFilterPriority;

typedef enum {
	MC_FILTER_FLAG_INCOMING = 1 << 0,
	MC_FILTER_FLAG_OUTCOMING = 1 << 1
} McFilterFlag;

struct _missioncontrol
{
    DBusGProxy parent;

    gboolean first_run;
    GHashTable *active_callbacks;
};


struct _missioncontrolclass
{
    DBusGProxyClass parent_class;
}; 

typedef struct _McAccountStatus {
    gchar *unique_name;
    TpConnectionStatus status;
    McPresence presence;
    TpConnectionStatusReason reason;
} McAccountStatus;

typedef void (*McCallback) (MissionControl *mc,
			    GError *error,
			    gpointer user_data);

#include <libmissioncontrol/mc-account.h>

GQuark mission_control_error_quark (void);
GType mission_control_get_type (void);


MissionControl *mission_control_new (DBusGConnection *connection);

void mission_control_set_presence (MissionControl *self,
				   McPresence presence,
				   const gchar *message,
				   McCallback callback,
				   gpointer user_data);

McPresence mission_control_get_presence (MissionControl *self, GError **error);
gchar *mission_control_get_presence_message (MissionControl *self,
					     GError **error);
McPresence mission_control_get_presence_actual (MissionControl *self,
						GError **error);
gchar *mission_control_get_presence_message_actual (MissionControl *self,
						    GError **error);

guint mission_control_request_channel (MissionControl *self,
				       McAccount *account,
				       const gchar *type,
				       guint handle,
				       TpHandleType handle_type,
				       McCallback callback,
				       gpointer user_data);

guint mission_control_request_channel_with_string_handle (MissionControl *self,
							  McAccount *account,
							  const gchar *type,
							  const gchar *handle,
							  TpHandleType handle_type,
							  McCallback callback,
							  gpointer user_data);

guint mission_control_request_channel_with_string_handle_and_vcard_field (MissionControl *self,
							  McAccount *account,
							  const gchar *type,
							  const gchar *handle,
							  const gchar *vcard_field,
							  TpHandleType handle_type,
							  McCallback callback,
							  gpointer user_data);

gboolean mission_control_cancel_channel_request (MissionControl *self,
						 guint operation_id,
						 GError **error);

void mission_control_connect_all_with_default_presence (MissionControl *self,
							McCallback callback,
							gpointer user_data);

guint mission_control_get_connection_status (MissionControl *self,
					     McAccount *account,
					     GError **error);

GSList *mission_control_get_online_connections (MissionControl *self,
						GError **error);

TpConn *mission_control_get_connection (MissionControl *self,
					McAccount *account, GError **error);

McAccount *mission_control_get_account_for_connection (MissionControl *self,
						       TpConn *connection,
						       GError **error);

gint mission_control_get_used_channels_count (MissionControl *self,
					      GQuark type, GError **error);

typedef void (*McGetCurrentStatusCallback) (MissionControl *mc,
					    McStatus status,
					    McPresence presence,
					    McPresence requested_presence,
					    McAccountStatus *accounts,
					    gsize n_accounts,
					    GError *error,
					    gpointer user_data);

void mission_control_get_current_status (MissionControl *self,
					 McGetCurrentStatusCallback callback,
					 gpointer user_data);

void mission_control_free_account_statuses (McAccountStatus *accounts);

gboolean mission_control_remote_avatar_changed (MissionControl *self,
						TpConn *connection,
						guint contact_id,
						const gchar *token,
						GError **error);

gboolean mission_control_register_filter (MissionControl *self,
					  const gchar *bus_name,
					  const gchar *object_path,
					  const gchar *channel_type,
					  McFilterPriority priority,
					  McFilterFlag flags,
					  GError **error);

#endif