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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
|
/**
* This file is a part of the Cairo-Dock project
*
* Copyright : (C) see the 'copyright' file.
* E-mail : see the 'copyright' file.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/******************************************************************************
exemples :
----------
dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.CreateLauncherFromScratch string:inkscape string:yep string:rien string:none
dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.SetLabel string:new_label string:icon_name string:any string:none
dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.SetQuickInfo string:123 string:none string:none string:dustbin
dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.Animate string:default int32:2 string:any string:firefox string:none
dbus-send --session --dest=org.cairodock.CairoDock /org/cairodock/CairoDock org.cairodock.CairoDock.SetIcon string:firefox-3.0 string:any string:nautilus string:none
******************************************************************************/
#include <fcntl.h> // O_RDONLY
#include <unistd.h> // open, read, close
#define __USE_POSIX
#include <signal.h> // kill
#include <glib.h>
#include <glib/gstdio.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-bindings.h>
#include "interface-main-methods.h"
#include "dbus-main-spec.h"
#include "interface-applet-object.h"
#include "interface-applet-signals.h"
#include "applet-dbus.h"
#define DISTANT_DIR "3.1.0"
#define GETTEXT_NAME_EXTRAS "cairo-dock-plugins-extra"
#define LOCALE_DIR_NAME "locale"
///////////////////
/// MAIN OBJECT ///
///////////////////
G_DEFINE_TYPE(dbusMainObject, cd_dbus_main, G_TYPE_OBJECT);
static void cd_dbus_main_class_init(dbusMainObjectClass *klass)
{
cd_message("");
}
static void cd_dbus_main_init (dbusMainObject *pMainObject)
{
cd_message("");
// Initialise the DBus connection
pMainObject->connection = cairo_dock_get_session_connection ();
dbus_g_object_type_install_info(cd_dbus_main_get_type(), &dbus_glib_cd_dbus_main_object_info);
// Register DBUS path
dbus_g_connection_register_g_object(pMainObject->connection, myData.cBasePath, G_OBJECT(pMainObject));
}
//////////////////////////
/// MODULE REGISTERING ///
//////////////////////////
static void _on_init_module (CairoDockModuleInstance *pModuleInstance, GKeyFile *pKeyFile)
{
cd_debug ("%s ()", __func__);
//\_____________ On initialise l'icone.
cd_dbus_action_on_init_module (pModuleInstance);
//\_____________ On cree l'objet sur le bus.
dbusApplet *pDbusApplet = cd_dbus_create_remote_applet_object (pModuleInstance);
g_return_if_fail (pDbusApplet != NULL);
//\____________ On met a jour le fichier de conf si necessaire, c'est plus simple pour les applets.
if (pKeyFile != NULL)
{
if (cairo_dock_conf_file_needs_update (pKeyFile, pModuleInstance->pModule->pVisitCard->cModuleVersion))
{
///cairo_dock_flush_conf_file (pKeyFile, pModuleInstance->cConfFilePath, pModuleInstance->pModule->pVisitCard->cShareDataDir, pModuleInstance->pModule->pVisitCard->cConfFileName);
gchar *cTemplate = g_strdup_printf ("%s/%s", pModuleInstance->pModule->pVisitCard->cShareDataDir, pModuleInstance->pModule->pVisitCard->cConfFileName);
cairo_dock_upgrade_conf_file (pModuleInstance->cConfFilePath, pKeyFile, cTemplate);
g_free (cTemplate);
}
}
//\_____________ On (re)lance l'executable de l'applet.
cd_dbus_launch_applet_process (pModuleInstance, pDbusApplet);
}
static gboolean _cd_dbus_register_new_module (const gchar *cModuleName, const gchar *cDescription, const gchar *cAuthor, const gchar *cVersion, gint iCategory, const gchar *cIconName, const gchar *cShareDataDir, gboolean bMultiInstance, gboolean bActAsLauncher)
{
cd_message ("%s (%s)", __func__, cModuleName);
//\____________ on cree et on enregistre un nouveau module s'il n'existe pas deja.
CairoDockModule *pModule = cairo_dock_find_module_from_name (cModuleName);
if (pModule != NULL) // le module existe deja, rien a faire.
{
cd_warning ("this module (%s) is already registered", cModuleName);
if (pModule->cSoFilePath != NULL)
{
cd_warning ("an installed module already exists with this name (%s).", cModuleName);
return FALSE;
}
}
else // on enregistre ce nouveau module.
{
pModule = g_new0 (CairoDockModule, 1);
CairoDockVisitCard *pVisitCard = g_new0 (CairoDockVisitCard, 1);
pModule->pVisitCard = pVisitCard;
pVisitCard->cModuleName = g_strdup (cModuleName);
pVisitCard->iMajorVersionNeeded = 2;
pVisitCard->iMinorVersionNeeded = 1;
pVisitCard->iMicroVersionNeeded = 1;
pVisitCard->cPreviewFilePath = cShareDataDir ? g_strdup_printf ("%s/preview", cShareDataDir) : NULL;
pVisitCard->cGettextDomain = g_strdup (GETTEXT_NAME_EXTRAS);
pVisitCard->cUserDataDir = g_strdup (cModuleName);
pVisitCard->cShareDataDir = g_strdup (cShareDataDir);
pVisitCard->cConfFileName = g_strdup_printf ("%s.conf", cModuleName);
pVisitCard->cModuleVersion = g_strdup (cVersion);
pVisitCard->cAuthor = g_strdup (cAuthor);
pVisitCard->iCategory = iCategory;
if (cIconName != NULL)
pVisitCard->cIconFilePath = g_strdup (cIconName); // take the filename as it is, the path will be searched when needed only.
if (pVisitCard->cIconFilePath == NULL)
pVisitCard->cIconFilePath = (cShareDataDir ? g_strdup_printf ("%s/icon", cShareDataDir) : NULL);
pVisitCard->iSizeOfConfig = 4; // au cas ou ...
pVisitCard->iSizeOfData = 4; // au cas ou ...
pVisitCard->cDescription = g_strdup (cDescription);
pVisitCard->cTitle = g_strdup (dgettext (pVisitCard->cGettextDomain, cModuleName));
pVisitCard->iContainerType = CAIRO_DOCK_MODULE_CAN_DOCK | CAIRO_DOCK_MODULE_CAN_DESKLET;
pVisitCard->bMultiInstance = bMultiInstance;
pVisitCard->bActAsLauncher = bActAsLauncher; // ex.: XChat controls xchat/xchat-gnome, but it does that only after initializing; we need to know if it's a launcher before the taskbar is loaded, hence this parameter.
pModule->pInterface = g_new0 (CairoDockModuleInterface, 1);
pModule->pInterface->initModule = _on_init_module;
pModule->pInterface->stopModule = cd_dbus_emit_on_stop_module;
pModule->pInterface->reloadModule = cd_dbus_emit_on_reload_module;
if (! cairo_dock_register_module (pModule))
{
cairo_dock_free_module (pModule);
cd_warning ("registration of '%s' has failed.", cModuleName);
return FALSE;
}
}
return TRUE;
}
gboolean cd_dbus_register_module_in_dir (const gchar *cModuleName, const gchar *cThirdPartyPath)
{
cd_debug ("%s (%s, %s)", __func__, cModuleName, cThirdPartyPath);
gchar *cFilePath = g_strdup_printf ("%s/%s/auto-load.conf", cThirdPartyPath, cModuleName);
GKeyFile *pKeyFile = cairo_dock_open_key_file (cFilePath);
if (pKeyFile == NULL)
{
cd_warning ("file %s should not be here", cFilePath);
g_free (cFilePath);
return FALSE;
}
GError *error = NULL;
gchar *cDescription = g_key_file_get_string (pKeyFile, "Register", "description", &error);
if (error != NULL)
{
cd_warning (error->message);
g_error_free (error);
error = NULL;
}
gchar *cAuthor = g_key_file_get_string (pKeyFile, "Register", "author", &error);
if (error != NULL)
{
cd_warning (error->message);
g_error_free (error);
error = NULL;
}
gchar *cVersion = g_key_file_get_string (pKeyFile, "Register", "version", &error);
if (error != NULL)
{
cd_warning (error->message);
g_error_free (error);
error = NULL;
}
int iCategory = g_key_file_get_integer (pKeyFile, "Register", "category", &error);
if (error != NULL)
{
cd_warning (error->message);
g_error_free (error);
error = NULL;
iCategory = CAIRO_DOCK_CATEGORY_APPLET_ACCESSORY;
}
gchar *cIconName = g_key_file_get_string (pKeyFile, "Register", "icon", NULL); // NULL if not specified, in which case we use the "icon" file.
if (cIconName && *cIconName == '\0')
{
g_free (cIconName);
cIconName = NULL;
}
gboolean bMultiInstance = g_key_file_get_boolean (pKeyFile, "Register", "multi-instance", NULL); // false if not specified
gboolean bActAsLauncher = g_key_file_get_boolean (pKeyFile, "Register", "act as launcher", NULL); // false if not specified
gchar *cShareDataDir = g_strdup_printf ("%s/%s", cThirdPartyPath, cModuleName);
g_key_file_free (pKeyFile);
gboolean bActivationOk = _cd_dbus_register_new_module (cModuleName, cDescription, cAuthor, cVersion, iCategory, cIconName, cShareDataDir, bMultiInstance, bActAsLauncher);
g_free (cDescription);
g_free (cAuthor);
g_free (cVersion);
g_free (cIconName);
g_free (cShareDataDir);
g_free (cFilePath);
return bActivationOk;
}
static gboolean _cd_dbus_register_all_applets_in_dir (const gchar *cDirPath)
{
gboolean bAppletRegistered = FALSE;
const gchar *cFileName;
gchar *cThirdPartyPath = g_strdup_printf ("%s/%s", cDirPath, CD_DBUS_APPLETS_FOLDER);
GDir *dir = g_dir_open (cThirdPartyPath, 0, NULL); // si le repertoire n'existe pas, on ne veut pas de warning.
if (dir == NULL)
{
g_free (cThirdPartyPath);
return bAppletRegistered;
}
do
{
cFileName = g_dir_read_name (dir);
if (cFileName == NULL)
break ;
if (strcmp (cFileName, LOCALE_DIR_NAME) != 0)
bAppletRegistered |= cd_dbus_register_module_in_dir (cFileName, cThirdPartyPath);
}
while (1);
g_dir_close (dir);
g_free (cThirdPartyPath);
return bAppletRegistered;
}
/////////////////////
/// MODULE UPDATE ///
/////////////////////
static void _get_package_path (gchar *cModuleName)
{
const gchar *cSharePackagesDir = MY_APPLET_SHARE_DATA_DIR"/"CD_DBUS_APPLETS_FOLDER;
gchar *cUserPackagesDir = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CD_DBUS_APPLETS_FOLDER);
///gchar *cDistantPackagesDir = g_strdup_printf ("%s/%d.%d.%d", CD_DBUS_APPLETS_FOLDER, g_iMajorVersion, g_iMinorVersion, g_iMicroVersion);
const gchar *cDistantPackagesDir = CD_DBUS_APPLETS_FOLDER"/"DISTANT_DIR;
gchar *cPath = cairo_dock_get_package_path (cModuleName,
cSharePackagesDir,
cUserPackagesDir,
cDistantPackagesDir,
CAIRO_DOCK_UPDATED_PACKAGE);
cd_debug ("*** update of the applet '%s' -> got '%s'", cModuleName, cPath);
g_free (cPath);
g_free (cUserPackagesDir);
//g_free (cDistantPackagesDir);
}
static gboolean _apply_package_update (gchar *cModuleName)
{
CairoDockModule *pModule = cairo_dock_find_module_from_name (cModuleName);
if (pModule && pModule->pInstancesList != NULL) // applet active => reload it (pModule can be NULL in case of "locale").
{
cd_debug ("*** applet '%s' is active, reload it", cModuleName);
CairoDockModuleInstance *pModuleInstance = pModule->pInstancesList->data;
Icon *pIcon = pModuleInstance->pIcon;
CairoContainer *pContainer = pModuleInstance->pContainer;
// unregister the module, since anything can have changed, including its definition.
cairo_dock_unregister_module (cModuleName); // stoppe le module (toutes les instances), ce qui appelle stop_module, qui emet le signal 'stop' vers l'applet distante (qui du coup quitte), et enleve le module de la table. L'objet distant est detruit durant le stop.
// clean the dock from the remaining icon.
if (pIcon != NULL && pContainer != NULL) // par contre les icones restent, mais ne sont plus des applets (elles ont perdu leur module). On fait donc le menage.
{
if (CAIRO_DOCK_IS_DOCK (pContainer))
{
cairo_dock_detach_icon_from_dock (pIcon, CAIRO_DOCK (pContainer));
cairo_dock_free_icon (pIcon);
cairo_dock_update_dock_size (CAIRO_DOCK (pContainer));
cairo_dock_redraw_container (pContainer);
}
}
// now register again the updated module.
gchar *cThirdPartyPath = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CD_DBUS_APPLETS_FOLDER);
cd_dbus_register_module_in_dir (cModuleName, cThirdPartyPath);
g_free (cThirdPartyPath);
// and activate it again.
pModule = cairo_dock_find_module_from_name (cModuleName); // the module has been destroyed previously, so grab it again.
g_return_val_if_fail (pModule != NULL, TRUE);
cairo_dock_activate_module (pModule, NULL);
}
// get corresponding task and free it.
CairoDockTask *pUpdateTask = NULL;
GList *t;
for (t = myData.pUpdateTasksList; t != NULL; t = t->next)
{
pUpdateTask = t->data;
if (pUpdateTask->pSharedMemory && strcmp (pUpdateTask->pSharedMemory, cModuleName) == 0)
{
myData.pUpdateTasksList = g_list_remove_link (myData.pUpdateTasksList, t); /// g_list_delete_link ?...
cairo_dock_discard_task (pUpdateTask);
break;
}
}
return TRUE;
}
static void _check_update_package (const gchar *cModuleName, CairoDockPackage *pPackage, gpointer data)
{
cd_message ("*** %s (%s, %d)", __func__, cModuleName, pPackage->iType);
if (pPackage->iType == CAIRO_DOCK_UPDATED_PACKAGE)
{
gchar *cUserDirPath = g_strdup_printf ("%s/%s/%s", g_cCairoDockDataDir, CD_DBUS_APPLETS_FOLDER, cModuleName);
if (g_file_test (cUserDirPath, G_FILE_TEST_EXISTS))
{
cd_message ("*** the applet '%s' needs to be updated", cModuleName);
CairoDockTask *pUpdateTask = cairo_dock_new_task_full (0,
(CairoDockGetDataAsyncFunc) _get_package_path,
(CairoDockUpdateSyncFunc) _apply_package_update,
(GFreeFunc) g_free,
g_strdup (cModuleName));
myData.pUpdateTasksList = g_list_prepend (myData.pUpdateTasksList, pUpdateTask);
cairo_dock_launch_task (pUpdateTask);
}
}
}
static void _on_got_list (GHashTable *pPackagesTable, gpointer data)
{
if (pPackagesTable != NULL)
{
g_hash_table_foreach (pPackagesTable, (GHFunc) _check_update_package, NULL);
}
cairo_dock_discard_task (myData.pGetListTask);
myData.pGetListTask = NULL;
}
///////////////
/// SERVICE ///
///////////////
void cd_dbus_clean_up_processes (gboolean bAll)
{
static gchar cFilePathBuffer[23+1]; // /proc/12345/cmdline + 4octets de marge.
static gchar cContent[512+1];
GError *erreur = NULL;
GDir *dir = g_dir_open ("/proc", 0, &erreur);
if (erreur != NULL)
{
cd_warning ("Dbus : %s", erreur->message);
g_error_free (erreur);
return;
}
int iPid, iPPid;
const gchar *cPid;
while ((cPid = g_dir_read_name (dir)) != NULL)
{
// get the command line that spawned the process.
if (! g_ascii_isdigit (*cPid))
continue;
snprintf (cFilePathBuffer, 23, "/proc/%s/cmdline", cPid);
int pipe = open (cFilePathBuffer, O_RDONLY);
if (pipe <= 0)
continue ;
int iNbBytesRead;
if ((iNbBytesRead = read (pipe, cContent, sizeof (cContent))) <= 1) // ends with a nul char.
{
close (pipe);
continue;
}
close (pipe);
// search for the pattern "... progname 123", where spaces are nul char.
const gchar *str = cContent + iNbBytesRead - 2; // last non-nul char.
while (*str != '\0' && str != cContent) // search the previous nul char.
str --;
if (str == cContent) // not found
continue;
iPPid = atoi (str+1);
if (iPPid == 0) // not a pid.
continue;
str --; // skip the nul char.
while (*str != '\0' && str != cContent) // search the previous nul char.
str --;
if (str == cContent) // not found
continue;
if (strcmp (str+1, myData.cProgName) != 0) // not our program name.
continue;
// found, kill the applet process.
gchar *cProcFile = g_strdup_printf ("/proc/%d", iPPid);
if (bAll || ! g_file_test (cProcFile, G_FILE_TEST_EXISTS)) // old process
{
cd_message ("this applet (%s %s) is linked to an old gldi process (%d), kill it.", cContent, cPid, iPPid);
iPid = atoi (cPid);
kill (iPid, SIGKILL); // SIGTERM sometimes lets the process alive.
}
}
g_dir_close (dir);
}
void cd_dbus_launch_service (void)
{
g_return_if_fail (myData.pMainObject == NULL);
g_type_init();
cd_message ("dbus : launching service...");
//\____________ define the base path on the bus. So each program built on gldi has its own path on the gldi bus, and will place its applets under its own path.
const gchar *cProgName = g_get_prgname ();
g_return_if_fail (cProgName != NULL);
int n = strlen (cProgName);
gchar *cName1 = g_new0 (gchar, n+1); // prog name without '-' and '_'
gchar *cName2 = g_new0 (gchar, n+1); // same but with upper char after the '-' and '_'
int i, k=0;
for (i = 0; i < n; i ++)
{
if (cProgName[i] == '-' || cProgName[i] == '_')
continue;
cName1[k] = g_ascii_tolower (cProgName[i]);
if (i == 0 || cProgName[i-1] == '-' || cProgName[i-1] == '_')
cName2[k] = g_ascii_toupper (cProgName[i]);
else
cName2[k] = cName1[k];
k ++;
}
myData.cProgName = cProgName;
myData.cBasePath = g_strdup_printf ("/org/%s/%s", cName1, cName2);
g_free (cName1);
g_free (cName2);
//\____________ kill all the orphean applets (for instance if the dock has crashed, or if it was interrupted by a CTRL+C, or if it stopped and the applet was busy and didn't receive the stop event (dbus-timeout)).
cd_dbus_clean_up_processes (FALSE); // FALSE <=> from old gldi instances
//\____________ Register the service name (the service name is registerd once by the first gldi instance).
cairo_dock_register_service_name ("org.cairodock.CairoDock"); /// what happens if the gldi instance that had registered the name quits while a 2nd instance remains ? do we need to queue ?...
//\____________ create the main object on the bus.
myData.pMainObject = g_object_new (cd_dbus_main_get_type(), NULL); // call cd_dbus_main_class_init() and cd_dbus_main_init().
//\____________ register the applets installed in the default folders.
gboolean bAppletRegistered = FALSE;
bAppletRegistered |= _cd_dbus_register_all_applets_in_dir (MY_APPLET_SHARE_DATA_DIR);
bAppletRegistered |= _cd_dbus_register_all_applets_in_dir (g_cCairoDockDataDir);
//\____________ internationalize the applets.
gchar *cLocaleDir = g_strdup_printf ("%s/"CD_DBUS_APPLETS_FOLDER"/"LOCALE_DIR_NAME, g_cCairoDockDataDir); // user version of /usr/share/locale
if (! g_file_test (cLocaleDir, G_FILE_TEST_EXISTS)) // translations not downloaded yet.
{
gchar *cUserAppletsFolder = g_strdup_printf ("%s/"CD_DBUS_APPLETS_FOLDER, g_cCairoDockDataDir);
if (! g_file_test (cUserAppletsFolder, G_FILE_TEST_EXISTS))
{
if (g_mkdir (cUserAppletsFolder, 7*8*8+7*8+5) != 0) // create an empty folder; since there is no date file, the "locale" package will be seen as "to be updated" by the package manager, which will therefore download it.
cd_warning ("couldn't create '%s'; third-party applets can't be added", cUserAppletsFolder);
}
g_free (cUserAppletsFolder);
if (g_mkdir (cLocaleDir, 7*8*8+7*8+5) != 0) // create an empty folder; since there is no date file, the "locale" package will be seen as "to be updated" by the package manager, and will therefore download it.
cd_warning ("couldn't create '%s'; applets won't be translated", cLocaleDir);
}
bindtextdomain (GETTEXT_NAME_EXTRAS, cLocaleDir); // bind the applets' domain to the user locale folder.
bind_textdomain_codeset (GETTEXT_NAME_EXTRAS, "UTF-8");
g_free (cLocaleDir);
//\____________ download in background the list of existing applets.
if (bAppletRegistered) // only if some third-party applets are present on the disk.
{
const gchar *cSharePackagesDir = NULL; // no share data dir, since we can't write in /usr
gchar *cUserPackagesDir = g_strdup_printf ("%s/%s", g_cCairoDockDataDir, CD_DBUS_APPLETS_FOLDER);
const gchar *cDistantPackagesDir = CD_DBUS_APPLETS_FOLDER"/"DISTANT_DIR;
myData.pGetListTask = cairo_dock_list_packages_async (cSharePackagesDir,
cUserPackagesDir,
cDistantPackagesDir,
(CairoDockGetPackagesFunc) _on_got_list,
NULL, // data
NULL); // table
g_free (cUserPackagesDir);
}
//\____________ Start the bridge to Unity Launcher API.
/* launch it asap, because if another Unity claims the bus before us,
* the messages will be emitted on the bus, and we might miss them.
*/
#ifdef DBUSMENU_GTK_FOUND // need SetMenu => DBusMenu
if (myConfig.bLaunchLauncherAPIDaemon)
cairo_dock_launch_command (CD_PLUGINS_DIR"/cairo-dock-launcher-API-daemon");
#endif
}
///////////////////
/// MARSHALLERS ///
///////////////////
// must be in this file, otherwise we get include hell because of the generated code in *-spec.h
void cd_dbus_marshal_VOID__INT_STRING (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__INT_STRING) (gpointer data1,
gint arg_1,
gchar *arg_2,
gpointer data2);
register GMarshalFunc_VOID__INT_STRING callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__INT_STRING) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_int (param_values + 1),
g_marshal_value_peek_string (param_values + 2),
data2);
}
void cd_dbus_marshal_VOID__BOOLEAN_STRING (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__BOOLEAN_STRING) (gpointer data1,
gboolean arg_1,
gchar *arg_2,
gpointer data2);
register GMarshalFunc_VOID__BOOLEAN_STRING callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__BOOLEAN_STRING) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_boolean (param_values + 1),
g_marshal_value_peek_string (param_values + 2),
data2);
}
void cd_dbus_marshal_VOID__STRING_STRING (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__STRING_STRING) (gpointer data1,
gchar *arg_1,
gchar *arg_2,
gpointer data2);
register GMarshalFunc_VOID__STRING_STRING callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__STRING_STRING) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_string (param_values + 1),
g_marshal_value_peek_string (param_values + 2),
data2);
}
void cd_dbus_marshal_VOID__VALUE (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__VALUE) (gpointer data1,
GValue *arg_1,
gpointer data2);
register GMarshalFunc_VOID__VALUE callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 2); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__VALUE) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_pointer (param_values + 1),
data2);
}
void cd_dbus_marshal_VOID__INT_VALUE (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__INT_VALUE) (gpointer data1,
gint arg_1,
GValue *arg_2,
gpointer data2);
register GMarshalFunc_VOID__INT_VALUE callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__INT_VALUE) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_int (param_values + 1),
g_marshal_value_peek_pointer (param_values + 2),
data2);
}
void cd_dbus_marshal_VOID__VALUE_STRING (GClosure *closure,
GValue *return_value G_GNUC_UNUSED,
guint n_param_values,
const GValue *param_values,
gpointer invocation_hint G_GNUC_UNUSED,
gpointer marshal_data)
{
//g_print ("%s ()\n", __func__);
typedef void (*GMarshalFunc_VOID__VALUE_STRING) (gpointer data1,
GValue *arg_1,
gchar *arg_2,
gpointer data2);
register GMarshalFunc_VOID__VALUE_STRING callback;
register GCClosure *cc = (GCClosure*) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 3); // return_value est NULL ici, car la callback ne renvoit rien.
if (G_CCLOSURE_SWAP_DATA (closure))
{
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
}
else
{
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback = (GMarshalFunc_VOID__VALUE_STRING) (marshal_data ? marshal_data : cc->callback);
callback (data1,
g_marshal_value_peek_pointer (param_values + 1),
g_marshal_value_peek_string (param_values + 2),
data2);
}
|