This repository has been archived by the owner on Jun 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
smd-applet.c
5677 lines (5419 loc) · 176 KB
/
smd-applet.c
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
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* smd-applet.c generated by valac 0.30.0, the Vala compiler
* generated from smd-applet.vala, do not modify */
/* Released under the terms of GPLv3 or at your option any later version.*/
/* No warranties.*/
/* Copyright Enrico Tassi <[email protected]>*/
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <gio/gio.h>
#include <gee.h>
#include <gtk/gtk.h>
#include <libnotify/notify.h>
#include <glib/gstdio.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <gdk/gdk.h>
#include "smd-config.h"
#include <gobject/gvaluecollector.h>
#define TYPE_NETWORK_MANAGER (network_manager_get_type ())
#define NETWORK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NETWORK_MANAGER, NetworkManager))
#define IS_NETWORK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NETWORK_MANAGER))
#define NETWORK_MANAGER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_NETWORK_MANAGER, NetworkManagerIface))
typedef struct _NetworkManager NetworkManager;
typedef struct _NetworkManagerIface NetworkManagerIface;
#define TYPE_NETWORK_MANAGER_PROXY (network_manager_proxy_get_type ())
typedef GDBusProxy NetworkManagerProxy;
typedef GDBusProxyClass NetworkManagerProxyClass;
#define TYPE_EVENT (event_get_type ())
#define EVENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_EVENT, Event))
#define EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_EVENT, EventClass))
#define IS_EVENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_EVENT))
#define IS_EVENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_EVENT))
#define EVENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_EVENT, EventClass))
typedef struct _Event Event;
typedef struct _EventClass EventClass;
typedef struct _EventPrivate EventPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _event_unref0(var) ((var == NULL) ? NULL : (var = (event_unref (var), NULL)))
typedef struct _ParamSpecEvent ParamSpecEvent;
#define TYPE_SMD_APPLET (smd_applet_get_type ())
#define SMD_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SMD_APPLET, smdApplet))
#define SMD_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SMD_APPLET, smdAppletClass))
#define IS_SMD_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SMD_APPLET))
#define IS_SMD_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SMD_APPLET))
#define SMD_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SMD_APPLET, smdAppletClass))
typedef struct _smdApplet smdApplet;
typedef struct _smdAppletClass smdAppletClass;
typedef struct _smdAppletPrivate smdAppletPrivate;
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __g_list_free__g_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_free0_ (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_match_info_unref0(var) ((var == NULL) ? NULL : (var = (g_match_info_unref (var), NULL)))
#define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _g_list_free0(var) ((var == NULL) ? NULL : (var = (g_list_free (var), NULL)))
#define _g_dir_close0(var) ((var == NULL) ? NULL : (var = (g_dir_close (var), NULL)))
#define _g_option_context_free0(var) ((var == NULL) ? NULL : (var = (g_option_context_free (var), NULL)))
typedef enum {
EXIT_ABORT
} Exit;
#define EXIT exit_quark ()
struct _NetworkManagerIface {
GTypeInterface parent_iface;
guint (*get_state) (NetworkManager* self);
};
struct _Event {
GTypeInstance parent_instance;
volatile int ref_count;
EventPrivate * priv;
gchar* message;
gchar* message_icon;
gboolean enter_network_error_mode;
gboolean enter_error_mode;
gboolean transient_error_message;
gchar* context;
gchar* cause;
gchar* permissions;
gchar* mail_name;
gchar* mail_body;
GeeArrayList* commands;
};
struct _EventClass {
GTypeClass parent_class;
void (*finalize) (Event *self);
};
struct _ParamSpecEvent {
GParamSpec parent_instance;
};
struct _smdApplet {
GtkApplication parent_instance;
smdAppletPrivate * priv;
};
struct _smdAppletClass {
GtkApplicationClass parent_class;
};
struct _smdAppletPrivate {
GtkBuilder* builder;
GtkStatusIcon* si;
GtkWindow* win;
GtkWindow* err_win;
GtkNotebook* notebook;
GtkSwitch* sync_active;
GtkComboBoxText* cblogs;
GeeArrayList* lognames;
GSettings* settings;
GThread* thread;
gboolean thread_die;
GPid pid;
GMutex events_lock;
GeeArrayList* events;
gboolean error_mode;
gboolean network_error_mode;
gboolean config_wait_mode;
GHashTable* command_hash;
NetworkManager* net_manager;
NotifyNotification* notification;
gboolean notification_server_has_persistence;
};
struct _Block1Data {
int _ref_count_;
smdApplet* self;
GtkSwitch* bnotify;
GtkSwitch* bautostart;
};
extern gboolean verbose;
gboolean verbose = FALSE;
static gpointer event_parent_class = NULL;
extern gchar* SMD_LOGS_DIR;
gchar* SMD_LOGS_DIR = NULL;
extern gchar* SMD_LOOP_CFG;
gchar* SMD_LOOP_CFG = NULL;
extern gchar* SMD_PP_DEF_CFG;
gchar* SMD_PP_DEF_CFG = NULL;
extern gchar* XDG_AUTORUN_FILE;
gchar* XDG_AUTORUN_FILE = NULL;
static gpointer smd_applet_parent_class = NULL;
extern gchar* smd_applet_smd_loop_cmd;
gchar* smd_applet_smd_loop_cmd = NULL;
extern gchar* smd_applet_smd_applet_ui;
gchar* smd_applet_smd_applet_ui = NULL;
extern gchar* smd_applet_smd_push_cmd;
gchar* smd_applet_smd_push_cmd = NULL;
extern gchar* smd_applet_smd_applet_desktop;
gchar* smd_applet_smd_applet_desktop = NULL;
static gchar* smd_applet_menu_ui;
static gchar* smd_applet_menu_ui = NULL;
GQuark exit_quark (void);
void debug (const gchar* message);
GType network_manager_get_type (void) G_GNUC_CONST;
GType network_manager_proxy_get_type (void) G_GNUC_CONST;
guint network_manager_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
guint network_manager_get_state (NetworkManager* self);
static void network_manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters);
static void _dbus_handle_network_manager_state_changed (NetworkManager* self, GVariant* parameters);
static guint network_manager_dbus_proxy_get_state (NetworkManager* self);
static void network_manager_proxy_network_manager_interface_init (NetworkManagerIface* iface);
static void network_manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
static GVariant* network_manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
static GVariant* _dbus_network_manager_get_state (NetworkManager* self);
static gboolean network_manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
static void _dbus_network_manager_state_changed (GObject* _sender, guint state, gpointer* _data);
static void _network_manager_unregister_object (gpointer user_data);
#define NM_SERVICE "org.freedesktop.NetworkManager"
#define NM_PATH "/org/freedesktop/NetworkManager"
gboolean is_nm_connected (guint code);
gpointer event_ref (gpointer instance);
void event_unref (gpointer instance);
GParamSpec* param_spec_event (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_event (GValue* value, gpointer v_object);
void value_take_event (GValue* value, gpointer v_object);
gpointer value_get_event (const GValue* value);
GType event_get_type (void) G_GNUC_CONST;
enum {
EVENT_DUMMY_PROPERTY
};
Event* event_error (const gchar* account, const gchar* host, const gchar* context, const gchar* cause, const gchar* permissions, const gchar* mail_name, const gchar* mail_body, GeeArrayList* commands);
Event* event_new (void);
Event* event_construct (GType object_type);
Event* event_generic_error (const gchar* cause);
Event* event_network_error (void);
Event* event_stats (const gchar* account, const gchar* host, gint new_mails, gint del_mails);
gboolean event_is_error_event (Event* self);
static void event_finalize (Event* obj);
#define SMD_LOOP "/bin/smd-loop"
#define SMD_PUSH "/bin/smd-push"
#define SMD_APPLET_UI "/share/syncmaildir-applet/smd-applet.ui"
#define SMD_APPLET_DESKTOP "/share/applications/smd-applet.desktop"
#define GNOME_AUTOSTART_DISABLED "X-GNOME-Autostart-enabled=false"
GType smd_applet_get_type (void) G_GNUC_CONST;
#define SMD_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_SMD_APPLET, smdAppletPrivate))
enum {
SMD_APPLET_DUMMY_PROPERTY
};
#define SMD_APPLET_key_newmail "notify-new-mail"
smdApplet* smd_applet_new (GError** error);
smdApplet* smd_applet_construct (GType object_type, GError** error);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void ___lambda4_ (smdApplet* self, guint s);
static void ____lambda4__network_manager_state_changed (NetworkManager* _sender, guint state, gpointer self);
static void smd_applet_update_logcontents (smdApplet* self);
static void __lambda5_ (Block1Data* _data1_);
static void ___lambda5__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void __lambda6_ (Block1Data* _data1_);
static void ___lambda6__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void smd_applet_close_err_action (smdApplet* self, GtkButton* b);
static void _smd_applet_close_err_action_gtk_button_clicked (GtkButton* _sender, gpointer self);
static void __lambda8_ (smdApplet* self, GtkButton* b);
static gboolean smd_applet_is_smd_loop_configured (smdApplet* self);
static void ___lambda8__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void __lambda9_ (smdApplet* self, GtkButton* b);
static gboolean smd_applet_is_smd_pushpull_configured (smdApplet* self);
static void ___lambda9__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void __lambda10_ (smdApplet* self);
static void smd_applet_unpause (smdApplet* self);
static void smd_applet_pause (smdApplet* self);
static void ___lambda10__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
static void smd_applet_update_loglist (smdApplet* self);
static gboolean __lambda11_ (smdApplet* self);
static gboolean ___lambda11__gsource_func (gpointer self);
static void __lambda12_ (smdApplet* self, GtkStatusIcon* s);
static void ___lambda12__gtk_status_icon_activate (GtkStatusIcon* _sender, gpointer self);
static void __lambda13_ (smdApplet* self);
static void ___lambda13__g_application_activate (GApplication* _sender, gpointer self);
static void __lambda14_ (smdApplet* self);
static void ___lambda14__g_simple_action_activate (GSimpleAction* _sender, GVariant* parameter, gpointer self);
static void _g_object_unref0_ (gpointer var);
static void _g_free0_ (gpointer var);
static void _g_list_free__g_free0_ (GList* self);
static void* smd_applet_smdThread (smdApplet* self);
static gboolean smd_applet_run_smd_loop (smdApplet* self, GError** error);
static void smd_applet_start_smdThread (smdApplet* self, gboolean force);
static gpointer _smd_applet_smdThread_gthread_func (gpointer self);
static gboolean smd_applet_eval_smd_loop_error_message (smdApplet* self, const gchar* args, const gchar* account, const gchar* host, GError** error);
static gboolean smd_applet_eval_smd_loop_message (smdApplet* self, const gchar* s);
static void ___lambda7_ (smdApplet* self);
static void ____lambda7__gspawn_child_setup_func (gpointer self);
static gboolean smd_applet_eat_event (smdApplet* self);
static void ______lambda15_ (smdApplet* self, NotifyNotification* not, const gchar* action);
static void _______lambda15__notify_action_callback (NotifyNotification* notification, const gchar* action, gpointer self);
static void ______lambda16_ (smdApplet* self, GtkButton* b);
static void _______lambda16__gtk_button_clicked (GtkButton* _sender, gpointer self);
static void smd_applet_reset_to_regular_run (smdApplet* self, gboolean force);
static gboolean smd_applet_close_err_event (smdApplet* self, GdkEventAny* e);
static gboolean smd_applet_close_prefs_event (smdApplet* self, GdkEventAny* e);
static void smd_applet_close_prefs (smdApplet* self);
static gboolean smd_applet_is_smd_stack_configured (smdApplet* self);
void smd_applet_start (smdApplet* self, GError** error);
static gboolean _smd_applet_eat_event_gsource_func (gpointer self);
static gboolean _smd_applet_close_prefs_event_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static gboolean _smd_applet_close_err_event_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static void ___lambda17_ (smdApplet* self, NotifyNotification* n, const gchar* a);
static void ____lambda17__notify_action_callback (NotifyNotification* notification, const gchar* action, gpointer self);
static void smd_applet_finalize (GObject* obj);
gint _vala_main (gchar** args, int args_length1);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_clear_GMutex (GMutex * mutex);
static void _vala_clear_GRecMutex (GRecMutex * mutex);
static void _vala_clear_GRWLock (GRWLock * mutex);
static void _vala_clear_GCond (GCond * mutex);
static const GDBusMethodInfo * const _network_manager_dbus_method_info[] = {NULL};
static const GDBusArgInfo _network_manager_dbus_arg_info_state_changed_state = {-1, "state", "u"};
static const GDBusArgInfo * const _network_manager_dbus_arg_info_state_changed[] = {&_network_manager_dbus_arg_info_state_changed_state, NULL};
static const GDBusSignalInfo _network_manager_dbus_signal_info_state_changed = {-1, "StateChanged", (GDBusArgInfo **) (&_network_manager_dbus_arg_info_state_changed)};
static const GDBusSignalInfo * const _network_manager_dbus_signal_info[] = {&_network_manager_dbus_signal_info_state_changed, NULL};
static const GDBusPropertyInfo _network_manager_dbus_property_info_state = {-1, "State", "u", G_DBUS_PROPERTY_INFO_FLAGS_READABLE};
static const GDBusPropertyInfo * const _network_manager_dbus_property_info[] = {&_network_manager_dbus_property_info_state, NULL};
static const GDBusInterfaceInfo _network_manager_dbus_interface_info = {-1, "org.freedesktop.NetworkManager", (GDBusMethodInfo **) (&_network_manager_dbus_method_info), (GDBusSignalInfo **) (&_network_manager_dbus_signal_info), (GDBusPropertyInfo **) (&_network_manager_dbus_property_info)};
static const GDBusInterfaceVTable _network_manager_dbus_interface_vtable = {network_manager_dbus_interface_method_call, network_manager_dbus_interface_get_property, network_manager_dbus_interface_set_property};
GQuark exit_quark (void) {
return g_quark_from_static_string ("exit-quark");
}
void debug (const gchar* message) {
gboolean _tmp0_ = FALSE;
g_return_if_fail (message != NULL);
_tmp0_ = verbose;
if (_tmp0_) {
FILE* _tmp1_ = NULL;
const gchar* _tmp2_ = NULL;
_tmp1_ = stderr;
_tmp2_ = message;
fprintf (_tmp1_, "DEBUG: %s\n", _tmp2_);
}
}
guint network_manager_get_state (NetworkManager* self) {
g_return_val_if_fail (self != NULL, 0U);
return NETWORK_MANAGER_GET_INTERFACE (self)->get_state (self);
}
static void network_manager_base_init (NetworkManagerIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
g_signal_new ("state_changed", TYPE_NETWORK_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
}
}
GType network_manager_get_type (void) {
static volatile gsize network_manager_type_id__volatile = 0;
if (g_once_init_enter (&network_manager_type_id__volatile)) {
static const GTypeInfo g_define_type_info = { sizeof (NetworkManagerIface), (GBaseInitFunc) network_manager_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
GType network_manager_type_id;
network_manager_type_id = g_type_register_static (G_TYPE_INTERFACE, "NetworkManager", &g_define_type_info, 0);
g_type_interface_add_prerequisite (network_manager_type_id, G_TYPE_OBJECT);
g_type_set_qdata (network_manager_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) network_manager_proxy_get_type);
g_type_set_qdata (network_manager_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.NetworkManager");
g_type_set_qdata (network_manager_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_network_manager_dbus_interface_info));
g_type_set_qdata (network_manager_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) network_manager_register_object);
g_once_init_leave (&network_manager_type_id__volatile, network_manager_type_id);
}
return network_manager_type_id__volatile;
}
G_DEFINE_TYPE_EXTENDED (NetworkManagerProxy, network_manager_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_NETWORK_MANAGER, network_manager_proxy_network_manager_interface_init) )
static void network_manager_proxy_class_init (NetworkManagerProxyClass* klass) {
G_DBUS_PROXY_CLASS (klass)->g_signal = network_manager_proxy_g_signal;
}
static void _dbus_handle_network_manager_state_changed (NetworkManager* self, GVariant* parameters) {
GVariantIter _arguments_iter;
guint state = 0U;
GVariant* _tmp0_;
g_variant_iter_init (&_arguments_iter, parameters);
_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
state = g_variant_get_uint32 (_tmp0_);
g_variant_unref (_tmp0_);
g_signal_emit_by_name (self, "state-changed", state);
}
static void network_manager_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) {
if (strcmp (signal_name, "StateChanged") == 0) {
_dbus_handle_network_manager_state_changed ((NetworkManager*) proxy, parameters);
}
}
static void network_manager_proxy_init (NetworkManagerProxy* self) {
}
static guint network_manager_dbus_proxy_get_state (NetworkManager* self) {
GVariant *_inner_reply;
guint _result;
_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "State");
if (!_inner_reply) {
GVariant *_arguments;
GVariant *_reply;
GVariantBuilder _arguments_builder;
g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.freedesktop.NetworkManager"));
g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("State"));
_arguments = g_variant_builder_end (&_arguments_builder);
_reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
if (!_reply) {
return 0U;
}
g_variant_get (_reply, "(v)", &_inner_reply);
g_variant_unref (_reply);
}
_result = g_variant_get_uint32 (_inner_reply);
g_variant_unref (_inner_reply);
return _result;
}
static void network_manager_proxy_network_manager_interface_init (NetworkManagerIface* iface) {
iface->get_state = network_manager_dbus_proxy_get_state;
}
static void network_manager_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
g_object_unref (invocation);
}
static GVariant* _dbus_network_manager_get_state (NetworkManager* self) {
guint result;
GVariant* _reply;
result = network_manager_get_state (self);
_reply = g_variant_new_uint32 (result);
return _reply;
}
static GVariant* network_manager_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
if (strcmp (property_name, "State") == 0) {
return _dbus_network_manager_get_state (object);
}
return NULL;
}
static gboolean network_manager_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
gpointer* data;
gpointer object;
data = user_data;
object = data[0];
return FALSE;
}
static void _dbus_network_manager_state_changed (GObject* _sender, guint state, gpointer* _data) {
GDBusConnection * _connection;
const gchar * _path;
GVariant *_arguments;
GVariantBuilder _arguments_builder;
_connection = _data[1];
_path = _data[2];
g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (state));
_arguments = g_variant_builder_end (&_arguments_builder);
g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.NetworkManager", "StateChanged", _arguments, NULL);
}
guint network_manager_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
guint result;
gpointer *data;
data = g_new (gpointer, 3);
data[0] = g_object_ref (object);
data[1] = g_object_ref (connection);
data[2] = g_strdup (path);
result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_network_manager_dbus_interface_info), &_network_manager_dbus_interface_vtable, data, _network_manager_unregister_object, error);
if (!result) {
return 0;
}
g_signal_connect (object, "state-changed", (GCallback) _dbus_network_manager_state_changed, data);
return result;
}
static void _network_manager_unregister_object (gpointer user_data) {
gpointer* data;
data = user_data;
g_signal_handlers_disconnect_by_func (data[0], _dbus_network_manager_state_changed, data);
g_object_unref (data[0]);
g_object_unref (data[1]);
g_free (data[2]);
g_free (data);
}
gboolean is_nm_connected (guint code) {
gboolean result = FALSE;
gboolean _tmp0_ = FALSE;
guint _tmp1_ = 0U;
_tmp1_ = code;
if (_tmp1_ == ((guint) 3)) {
_tmp0_ = TRUE;
} else {
guint _tmp2_ = 0U;
_tmp2_ = code;
_tmp0_ = _tmp2_ == ((guint) 70);
}
result = _tmp0_;
return result;
}
static gpointer _g_object_ref0 (gpointer self) {
return self ? g_object_ref (self) : NULL;
}
Event* event_error (const gchar* account, const gchar* host, const gchar* context, const gchar* cause, const gchar* permissions, const gchar* mail_name, const gchar* mail_body, GeeArrayList* commands) {
Event* result = NULL;
Event* e = NULL;
Event* _tmp0_ = NULL;
gchar* _tmp1_ = NULL;
gchar* _tmp2_ = NULL;
const gchar* _tmp3_ = NULL;
gchar* _tmp4_ = NULL;
const gchar* _tmp5_ = NULL;
gchar* _tmp6_ = NULL;
const gchar* _tmp7_ = NULL;
gchar* _tmp8_ = NULL;
const gchar* _tmp9_ = NULL;
gchar* _tmp10_ = NULL;
const gchar* _tmp11_ = NULL;
gchar* _tmp12_ = NULL;
GeeArrayList* _tmp13_ = NULL;
GeeArrayList* _tmp14_ = NULL;
g_return_val_if_fail (account != NULL, NULL);
g_return_val_if_fail (host != NULL, NULL);
g_return_val_if_fail (context != NULL, NULL);
g_return_val_if_fail (cause != NULL, NULL);
g_return_val_if_fail (commands != NULL, NULL);
_tmp0_ = event_new ();
e = _tmp0_;
_tmp1_ = g_strdup ("An error occurred, click on the icon for more details");
_g_free0 (e->message);
e->message = _tmp1_;
_tmp2_ = g_strdup ("error");
_g_free0 (e->message_icon);
e->message_icon = _tmp2_;
e->enter_error_mode = TRUE;
_tmp3_ = cause;
_tmp4_ = g_strdup (_tmp3_);
_g_free0 (e->cause);
e->cause = _tmp4_;
_tmp5_ = context;
_tmp6_ = g_strdup (_tmp5_);
_g_free0 (e->context);
e->context = _tmp6_;
_tmp7_ = permissions;
_tmp8_ = g_strdup (_tmp7_);
_g_free0 (e->permissions);
e->permissions = _tmp8_;
_tmp9_ = mail_name;
_tmp10_ = g_strdup (_tmp9_);
_g_free0 (e->mail_name);
e->mail_name = _tmp10_;
_tmp11_ = mail_body;
_tmp12_ = g_strdup (_tmp11_);
_g_free0 (e->mail_body);
e->mail_body = _tmp12_;
_tmp13_ = commands;
_tmp14_ = _g_object_ref0 (_tmp13_);
_g_object_unref0 (e->commands);
e->commands = _tmp14_;
result = e;
return result;
}
Event* event_generic_error (const gchar* cause) {
Event* result = NULL;
Event* e = NULL;
Event* _tmp0_ = NULL;
const gchar* _tmp1_ = NULL;
gchar* _tmp2_ = NULL;
gchar* _tmp3_ = NULL;
g_return_val_if_fail (cause != NULL, NULL);
_tmp0_ = event_new ();
e = _tmp0_;
_tmp1_ = cause;
_tmp2_ = g_strconcat ("A failure occurred: ", _tmp1_, NULL);
_g_free0 (e->message);
e->message = _tmp2_;
_tmp3_ = g_strdup ("dialog-warning");
_g_free0 (e->message_icon);
e->message_icon = _tmp3_;
e->transient_error_message = TRUE;
result = e;
return result;
}
Event* event_network_error (void) {
Event* result = NULL;
Event* e = NULL;
Event* _tmp0_ = NULL;
gchar* _tmp1_ = NULL;
gchar* _tmp2_ = NULL;
_tmp0_ = event_new ();
e = _tmp0_;
_tmp1_ = g_strdup ("A persistent network failure occurred");
_g_free0 (e->message);
e->message = _tmp1_;
_tmp2_ = g_strdup ("dialog-warning");
_g_free0 (e->message_icon);
e->message_icon = _tmp2_;
e->enter_network_error_mode = TRUE;
result = e;
return result;
}
Event* event_stats (const gchar* account, const gchar* host, gint new_mails, gint del_mails) {
Event* result = NULL;
gchar* preamble = NULL;
const gchar* _tmp0_ = NULL;
gchar* _tmp1_ = NULL;
Event* e = NULL;
Event* _tmp2_ = NULL;
gboolean _tmp3_ = FALSE;
gint _tmp4_ = 0;
g_return_val_if_fail (account != NULL, NULL);
g_return_val_if_fail (host != NULL, NULL);
_tmp0_ = account;
_tmp1_ = g_strdup_printf ("Synchronize with %s:\n", _tmp0_);
preamble = _tmp1_;
_tmp2_ = event_new ();
e = _tmp2_;
_tmp4_ = new_mails;
if (_tmp4_ > 0) {
gint _tmp5_ = 0;
_tmp5_ = del_mails;
_tmp3_ = _tmp5_ > 0;
} else {
_tmp3_ = FALSE;
}
if (_tmp3_) {
Event* _tmp6_ = NULL;
const gchar* _tmp7_ = NULL;
gint _tmp8_ = 0;
gint _tmp9_ = 0;
gchar* _tmp10_ = NULL;
_tmp6_ = e;
_tmp7_ = preamble;
_tmp8_ = new_mails;
_tmp9_ = del_mails;
_tmp10_ = g_strdup_printf ("%s%d new messages\n%d deleted messages", _tmp7_, _tmp8_, _tmp9_);
_g_free0 (_tmp6_->message);
_tmp6_->message = _tmp10_;
} else {
gint _tmp11_ = 0;
_tmp11_ = new_mails;
if (_tmp11_ > 0) {
Event* _tmp12_ = NULL;
const gchar* _tmp13_ = NULL;
gint _tmp14_ = 0;
gchar* _tmp15_ = NULL;
_tmp12_ = e;
_tmp13_ = preamble;
_tmp14_ = new_mails;
_tmp15_ = g_strdup_printf ("%s%d new messages", _tmp13_, _tmp14_);
_g_free0 (_tmp12_->message);
_tmp12_->message = _tmp15_;
} else {
Event* _tmp16_ = NULL;
const gchar* _tmp17_ = NULL;
gint _tmp18_ = 0;
gchar* _tmp19_ = NULL;
_tmp16_ = e;
_tmp17_ = preamble;
_tmp18_ = del_mails;
_tmp19_ = g_strdup_printf ("%s%d deleted messages", _tmp17_, _tmp18_);
_g_free0 (_tmp16_->message);
_tmp16_->message = _tmp19_;
}
}
result = e;
_g_free0 (preamble);
return result;
}
gboolean event_is_error_event (Event* self) {
gboolean result = FALSE;
gboolean _tmp0_ = FALSE;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
g_return_val_if_fail (self != NULL, FALSE);
_tmp2_ = self->enter_error_mode;
if (_tmp2_) {
_tmp1_ = TRUE;
} else {
gboolean _tmp3_ = FALSE;
_tmp3_ = self->enter_network_error_mode;
_tmp1_ = _tmp3_;
}
if (_tmp1_) {
_tmp0_ = TRUE;
} else {
gboolean _tmp4_ = FALSE;
_tmp4_ = self->transient_error_message;
_tmp0_ = _tmp4_;
}
result = _tmp0_;
return result;
}
Event* event_construct (GType object_type) {
Event* self = NULL;
self = (Event*) g_type_create_instance (object_type);
return self;
}
Event* event_new (void) {
return event_construct (TYPE_EVENT);
}
static void value_event_init (GValue* value) {
value->data[0].v_pointer = NULL;
}
static void value_event_free_value (GValue* value) {
if (value->data[0].v_pointer) {
event_unref (value->data[0].v_pointer);
}
}
static void value_event_copy_value (const GValue* src_value, GValue* dest_value) {
if (src_value->data[0].v_pointer) {
dest_value->data[0].v_pointer = event_ref (src_value->data[0].v_pointer);
} else {
dest_value->data[0].v_pointer = NULL;
}
}
static gpointer value_event_peek_pointer (const GValue* value) {
return value->data[0].v_pointer;
}
static gchar* value_event_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
if (collect_values[0].v_pointer) {
Event* object;
object = collect_values[0].v_pointer;
if (object->parent_instance.g_class == NULL) {
return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
}
value->data[0].v_pointer = event_ref (object);
} else {
value->data[0].v_pointer = NULL;
}
return NULL;
}
static gchar* value_event_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
Event** object_p;
object_p = collect_values[0].v_pointer;
if (!object_p) {
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
}
if (!value->data[0].v_pointer) {
*object_p = NULL;
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
*object_p = value->data[0].v_pointer;
} else {
*object_p = event_ref (value->data[0].v_pointer);
}
return NULL;
}
GParamSpec* param_spec_event (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
ParamSpecEvent* spec;
g_return_val_if_fail (g_type_is_a (object_type, TYPE_EVENT), NULL);
spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
G_PARAM_SPEC (spec)->value_type = object_type;
return G_PARAM_SPEC (spec);
}
gpointer value_get_event (const GValue* value) {
g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_EVENT), NULL);
return value->data[0].v_pointer;
}
void value_set_event (GValue* value, gpointer v_object) {
Event* old;
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_EVENT));
old = value->data[0].v_pointer;
if (v_object) {
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_EVENT));
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
value->data[0].v_pointer = v_object;
event_ref (value->data[0].v_pointer);
} else {
value->data[0].v_pointer = NULL;
}
if (old) {
event_unref (old);
}
}
void value_take_event (GValue* value, gpointer v_object) {
Event* old;
g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_EVENT));
old = value->data[0].v_pointer;
if (v_object) {
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_EVENT));
g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
value->data[0].v_pointer = v_object;
} else {
value->data[0].v_pointer = NULL;
}
if (old) {
event_unref (old);
}
}
static void event_class_init (EventClass * klass) {
event_parent_class = g_type_class_peek_parent (klass);
((EventClass *) klass)->finalize = event_finalize;
}
static void event_instance_init (Event * self) {
gchar* _tmp0_ = NULL;
self->message = NULL;
_tmp0_ = g_strdup ("gtk-about");
self->message_icon = _tmp0_;
self->enter_network_error_mode = FALSE;
self->enter_error_mode = FALSE;
self->transient_error_message = FALSE;
self->context = NULL;
self->cause = NULL;
self->permissions = NULL;
self->mail_name = NULL;
self->mail_body = NULL;
self->commands = NULL;
self->ref_count = 1;
}
static void event_finalize (Event* obj) {
Event * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_EVENT, Event);
g_signal_handlers_destroy (self);
_g_free0 (self->message);
_g_free0 (self->message_icon);
_g_free0 (self->context);
_g_free0 (self->cause);
_g_free0 (self->permissions);
_g_free0 (self->mail_name);
_g_free0 (self->mail_body);
_g_object_unref0 (self->commands);
}
GType event_get_type (void) {
static volatile gsize event_type_id__volatile = 0;
if (g_once_init_enter (&event_type_id__volatile)) {
static const GTypeValueTable g_define_type_value_table = { value_event_init, value_event_free_value, value_event_copy_value, value_event_peek_pointer, "p", value_event_collect_value, "p", value_event_lcopy_value };
static const GTypeInfo g_define_type_info = { sizeof (EventClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) event_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Event), 0, (GInstanceInitFunc) event_instance_init, &g_define_type_value_table };
static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
GType event_type_id;
event_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Event", &g_define_type_info, &g_define_type_fundamental_info, 0);
g_once_init_leave (&event_type_id__volatile, event_type_id);
}
return event_type_id__volatile;
}
gpointer event_ref (gpointer instance) {
Event* self;
self = instance;
g_atomic_int_inc (&self->ref_count);
return instance;
}
void event_unref (gpointer instance) {
Event* self;
self = instance;
if (g_atomic_int_dec_and_test (&self->ref_count)) {
EVENT_GET_CLASS (self)->finalize (self);
g_type_free_instance ((GTypeInstance *) self);
}
}
static Block1Data* block1_data_ref (Block1Data* _data1_) {
g_atomic_int_inc (&_data1_->_ref_count_);
return _data1_;
}
static void block1_data_unref (void * _userdata_) {
Block1Data* _data1_;
_data1_ = (Block1Data*) _userdata_;
if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
smdApplet* self;
self = _data1_->self;
_g_object_unref0 (_data1_->bautostart);
_g_object_unref0 (_data1_->bnotify);
_g_object_unref0 (self);
g_slice_free (Block1Data, _data1_);
}
}
static void ___lambda4_ (smdApplet* self, guint s) {
guint _tmp0_ = 0U;
gboolean _tmp1_ = FALSE;
_tmp0_ = s;
_tmp1_ = is_nm_connected (_tmp0_);
if (_tmp1_) {
GtkSwitch* _tmp2_ = NULL;
_tmp2_ = self->priv->sync_active;
gtk_switch_set_active (_tmp2_, TRUE);
} else {
GtkSwitch* _tmp3_ = NULL;
_tmp3_ = self->priv->sync_active;
gtk_switch_set_active (_tmp3_, FALSE);
}
}
static void ____lambda4__network_manager_state_changed (NetworkManager* _sender, guint state, gpointer self) {
___lambda4_ ((smdApplet*) self, state);
}
static void __lambda5_ (Block1Data* _data1_) {
smdApplet* self;
GSettings* _tmp0_ = NULL;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
self = _data1_->self;
_tmp0_ = self->priv->settings;
_tmp1_ = gtk_switch_get_active (_data1_->bnotify);
_tmp2_ = _tmp1_;
g_settings_set_boolean (_tmp0_, SMD_APPLET_key_newmail, _tmp2_);
}
static void ___lambda5__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
__lambda5_ (self);
}
static void __lambda6_ (Block1Data* _data1_) {
smdApplet* self;
gboolean _tmp0_ = FALSE;
gboolean _tmp1_ = FALSE;
GError * _inner_error_ = NULL;
self = _data1_->self;
_tmp0_ = gtk_switch_get_active (_data1_->bautostart);
_tmp1_ = _tmp0_;
if (_tmp1_) {
gchar* content = NULL;
{
const gchar* _tmp2_ = NULL;
gchar* _tmp3_ = NULL;
const gchar* _tmp4_ = NULL;
const gchar* _tmp5_ = NULL;
_tmp2_ = smd_applet_smd_applet_desktop;
g_file_get_contents (_tmp2_, &_tmp3_, NULL, &_inner_error_);
_g_free0 (content);
content = _tmp3_;
if (G_UNLIKELY (_inner_error_ != NULL)) {
if (_inner_error_->domain == G_FILE_ERROR) {
goto __catch5_g_file_error;
}
_g_free0 (content);
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp4_ = XDG_AUTORUN_FILE;
_tmp5_ = content;
g_file_set_contents (_tmp4_, _tmp5_, (gssize) -1, &_inner_error_);
if (G_UNLIKELY (_inner_error_ != NULL)) {
if (_inner_error_->domain == G_FILE_ERROR) {
goto __catch5_g_file_error;