| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
#if HAVE_CONFIG_H |
|---|
| 21 |
#include "config.h" |
|---|
| 22 |
#endif |
|---|
| 23 |
|
|---|
| 24 |
#include <glib/gi18n-lib.h> |
|---|
| 25 |
|
|---|
| 26 |
#include "tmut-ringtone-player.h" |
|---|
| 27 |
|
|---|
| 28 |
static GObjectClass *parent_class = NULL; |
|---|
| 29 |
|
|---|
| 30 |
static void |
|---|
| 31 |
tmut_ringtone_player_play_ringtone (TnyFolderObserver *self, TMutRingtone ringtone) |
|---|
| 32 |
{ |
|---|
| 33 |
switch (ringtone) |
|---|
| 34 |
{ |
|---|
| 35 |
case TMUT_RINGTONE_NEW_MESSAGE: |
|---|
| 36 |
default: |
|---|
| 37 |
g_printf (_("Play ringtone\n")); |
|---|
| 38 |
break; |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
static void |
|---|
| 43 |
tmut_ringtone_player_update (TnyFolderObserver *self, TnyFolderChange *change) |
|---|
| 44 |
{ |
|---|
| 45 |
TnyFolderChangeChanged changed = tny_folder_change_get_changed (change); |
|---|
| 46 |
|
|---|
| 47 |
if (changed & TNY_FOLDER_CHANGE_CHANGED_ADDED_HEADERS) |
|---|
| 48 |
tmut_ringtone_player_play_ringtone (self, TMUT_RINGTONE_NEW_MESSAGE); |
|---|
| 49 |
|
|---|
| 50 |
return; |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
TnyFolderObserver* |
|---|
| 62 |
tmut_ringtone_player_new (void) |
|---|
| 63 |
{ |
|---|
| 64 |
TMutRingtonePlayer *self = g_object_new (TMUT_TYPE_RINGTONE_PLAYER, NULL); |
|---|
| 65 |
|
|---|
| 66 |
return TNY_FOLDER_OBSERVER (self); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
static void |
|---|
| 71 |
tmut_ringtone_player_finalize (GObject *object) |
|---|
| 72 |
{ |
|---|
| 73 |
parent_class->finalize (object); |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
static void |
|---|
| 77 |
tmut_ringtone_player_instance_init (GTypeInstance *instance, gpointer g_class) |
|---|
| 78 |
{ |
|---|
| 79 |
return; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
static void |
|---|
| 83 |
tny_folder_observer_init (TnyFolderObserverIface *klass) |
|---|
| 84 |
{ |
|---|
| 85 |
klass->update= tmut_ringtone_player_update; |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
static void |
|---|
| 89 |
tmut_ringtone_player_class_init (TMutRingtonePlayerClass *klass) |
|---|
| 90 |
{ |
|---|
| 91 |
GObjectClass *object_class; |
|---|
| 92 |
|
|---|
| 93 |
parent_class = g_type_class_peek_parent (klass); |
|---|
| 94 |
object_class = (GObjectClass*) klass; |
|---|
| 95 |
|
|---|
| 96 |
object_class->finalize = tmut_ringtone_player_finalize; |
|---|
| 97 |
} |
|---|
| 98 |
|
|---|
| 99 |
GType |
|---|
| 100 |
tmut_ringtone_player_get_type (void) |
|---|
| 101 |
{ |
|---|
| 102 |
static GType type = 0; |
|---|
| 103 |
if (G_UNLIKELY(type == 0)) |
|---|
| 104 |
{ |
|---|
| 105 |
static const GTypeInfo info = |
|---|
| 106 |
{ |
|---|
| 107 |
sizeof (TMutRingtonePlayerClass), |
|---|
| 108 |
NULL, |
|---|
| 109 |
NULL, |
|---|
| 110 |
(GClassInitFunc) tmut_ringtone_player_class_init, |
|---|
| 111 |
NULL, |
|---|
| 112 |
NULL, |
|---|
| 113 |
sizeof (TMutRingtonePlayer), |
|---|
| 114 |
0, |
|---|
| 115 |
tmut_ringtone_player_instance_init, |
|---|
| 116 |
NULL |
|---|
| 117 |
}; |
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 |
static const GInterfaceInfo tny_folder_observer_info = |
|---|
| 121 |
{ |
|---|
| 122 |
(GInterfaceInitFunc) tny_folder_observer_init, |
|---|
| 123 |
NULL, |
|---|
| 124 |
NULL |
|---|
| 125 |
}; |
|---|
| 126 |
|
|---|
| 127 |
type = g_type_register_static (G_TYPE_OBJECT, |
|---|
| 128 |
"TMutRingtonePlayer", |
|---|
| 129 |
&info, 0); |
|---|
| 130 |
|
|---|
| 131 |
g_type_add_interface_static (type, TNY_TYPE_FOLDER_OBSERVER, |
|---|
| 132 |
&tny_folder_observer_info); |
|---|
| 133 |
|
|---|
| 134 |
} |
|---|
| 135 |
return type; |
|---|
| 136 |
} |
|---|