2
* This file is a part of the Cairo-Dock project
4
* Copyright : (C) see the 'copyright' file.
5
* based on indicator-me.c written by :
6
* Ted Gould <ted@canonical.com>
7
* Cody Russell <cody.russell@canonical.com>
8
* E-mail : see the 'copyright' file.
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 3
13
* of the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
#include <libindicator/indicator.h>
27
#include <libindicator/indicator-object.h>
28
#include <libindicator/indicator-service-manager.h>
30
#include "applet-struct.h"
31
#include "me-service-client.h"
32
#include "applet-me.h"
34
#define INDICATOR_ME_DBUS_OBJECT "/org/ayatana/indicator/me/menu"
35
#define INDICATOR_ME_SERVICE_DBUS_OBJECT "/org/ayatana/indicator/me/service"
36
#define INDICATOR_ME_SERVICE_DBUS_INTERFACE "org.ayatana.indicator.me.service"
37
#define INDICATOR_ME_DBUS_NAME "org.ayatana.indicator.me"
38
#define INDICATOR_ME_DBUS_VERSION 1
39
#define DEFAULT_ICON "user-offline"
47
username_cb (DBusGProxy * proxy, const char * username, GError *error, CairoDockModuleInstance *myApplet)
49
g_print (" + new username: '%s'\n", username);
50
CD_APPLET_SET_NAME_FOR_MY_ICON (username); // username peut etre NULL ou vide, c'est pas genant.
54
username_changed (DBusGProxy * proxy, gchar * username, CairoDockModuleInstance *myApplet)
56
g_print ("Changing username: '%s'\n", username);
58
return username_cb(proxy, username, NULL, myApplet);
62
status_icon_cb (DBusGProxy * proxy, const char * icons, GError *error, CairoDockModuleInstance *myApplet)
64
g_return_if_fail(icons != NULL);
65
g_return_if_fail(icons[0] != '\0');
66
g_print (" + new icon: '%s'\n", icons);
68
cd_indicator_set_icon (myData.pIndicator, icons);
69
CD_APPLET_REDRAW_MY_ICON;
75
status_icon_changed (DBusGProxy * proxy, gchar * icon, CairoDockModuleInstance *myApplet)
77
g_print ("Changing status icon: '%s'\n", icon);
79
return status_icon_cb(proxy, icon, NULL, myApplet);
82
void cd_me_on_connect (CairoDockModuleInstance *myApplet)
84
DBusGProxy * pServiceProxy = myData.pIndicator->pServiceProxy;
86
dbus_g_proxy_add_signal (pServiceProxy, "StatusIconsChanged", G_TYPE_STRING, G_TYPE_INVALID);
87
dbus_g_proxy_connect_signal (pServiceProxy, "StatusIconsChanged", G_CALLBACK(status_icon_changed), myApplet, NULL);
89
dbus_g_proxy_add_signal (pServiceProxy, "UserChanged", G_TYPE_STRING, G_TYPE_INVALID);
90
dbus_g_proxy_connect_signal (pServiceProxy, "UserChanged", G_CALLBACK(username_changed), myApplet, NULL);
93
void cd_me_on_disconnect (CairoDockModuleInstance *myApplet)
95
cd_warning ("It seems that the MeMenu is not available on this system");
96
status_icon_cb (NULL, DEFAULT_ICON, NULL, myApplet); // If we're disconnecting, go back to offline.
99
void cd_me_get_initial_values (CairoDockModuleInstance *myApplet)
101
// query the service to display initial values.
102
DBusGProxy * pServiceProxy = myData.pIndicator->pServiceProxy;
104
org_ayatana_indicator_me_service_status_icons_async (pServiceProxy,
105
(org_ayatana_indicator_me_service_status_icons_reply)status_icon_cb,
108
org_ayatana_indicator_me_service_pretty_user_name_async (pServiceProxy,
109
(org_ayatana_indicator_me_service_status_icons_reply)username_cb,