root/trunk/src/tmut-ringtone-player.c

Revision 73 (checked in by pvanhoof, 9 months ago)

2008-01-28 Philip Van Hoof <pvanhoof@gnome.org>

        • Adapted TMut to the latest Tinymail API changes in trunk.
Line 
1 /* TMut
2  * Copyright (C) 2006-2007 Philip Van Hoof <pvanhoof@gnome.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with self library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
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  * tmut_ringtone_player_new:
55  * @folder: a #TMutFolder instance
56  *
57  * Creates a folder monitor for @folder
58  *
59  * Return value: a new #TMutRingtonePlayer instance
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,   /* base_init */
109                         NULL,   /* base_finalize */
110                         (GClassInitFunc) tmut_ringtone_player_class_init,   /* class_init */
111                         NULL,   /* class_finalize */
112                         NULL,   /* class_data */
113                         sizeof (TMutRingtonePlayer),
114                         0,      /* n_preallocs */
115                         tmut_ringtone_player_instance_init,    /* instance_init */
116                         NULL
117                 };
118
119
120                 static const GInterfaceInfo tny_folder_observer_info =
121                 {
122                         (GInterfaceInitFunc) tny_folder_observer_init, /* interface_init */
123                         NULL,         /* interface_finalize */
124                         NULL          /* interface_data */
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 }
Note: See TracBrowser for help on using the browser.