Started updating FSO APIs
[gsmd2.git] / src / dbus_sms_object.c
blobdb159cb3a4a09874e823caf536461b5ebe6f62ed
1 /*
2 * dbus_sms_object.c
4 * Copyright(C) 2007,2008 Ixonos Plc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Boston, MA 02111.
22 * Written by
23 * Jukka Honkela
24 * Yi Zheng
25 * Matti Katila
26 * Vesa Pikki
27 * Heikki Paajanen
31 #include "dbus_sms_object.h"
32 #include "dbus_sms_glue.h"
33 #include "dbus_marshal.h"
34 #include "sms_interface.h"
35 #include <stdlib.h>
36 #include <stdio.h>
38 G_DEFINE_TYPE(DBusSmsObject, dbus_sms_object, G_TYPE_OBJECT)
42 static void
43 dbus_sms_object_class_init(DBusSmsObjectClass *klass)
45 /** Register our signals so that they can be emitted */
47 klass->message_sent = g_signal_new ("message_sent",
48 G_OBJECT_CLASS_TYPE (klass),
49 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
50 0, NULL, NULL, gsmd_smartphone_marshaller_VOID__BOOLEAN_STRING,
51 G_TYPE_NONE, 2, G_TYPE_BOOLEAN,G_TYPE_STRING);
53 klass->incoming_message = g_signal_new ("incoming_message",
54 G_OBJECT_CLASS_TYPE (klass),
55 G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
56 0, NULL, NULL, g_cclosure_marshal_VOID__INT,
57 G_TYPE_NONE, 1, G_TYPE_INT);
61 static void dbus_sms_object_init(DBusSmsObject *gsm)
63 dbus_g_object_type_install_info (DBUS_SMS_TYPE_OBJECT,
64 &dbus_glib_smartphone_sms_object_info);
67 void dbus_sms_object_finalize(GObject *obj)
69 //G_OBJECT_CLASS (parent_class)->finalize (obj);
70 //DBusSmsObject *gsm = (DBusSmsObject *) obj;
75 void gsmd_dbus_sms_uninitialize(DBusSmsObject *obj)
77 g_object_unref(obj);
82 /*********************Signal functions***********************/
83 void smartphone_sms_message_sent ( SMSIPCInterface *sms_ipc,
84 gboolean success,
85 const gchar* reason)
87 DBusSmsObject *obj = (DBusSmsObject*)sms_ipc->priv;
88 g_signal_emit (obj,
89 DBUS_SMS_OBJECT_GET_CLASS(obj)->message_sent,
90 0, success,reason);
93 void smartphone_sms_incoming_message (SMSIPCInterface *sms_ipc,
94 gint index)
96 DBusSmsObject *obj = (DBusSmsObject*)sms_ipc->priv;
97 g_signal_emit (obj,
98 DBUS_SMS_OBJECT_GET_CLASS(obj)->incoming_message,
99 0, index);
103 /*************************Methods**********************************************/
105 gboolean smartphone_sms_get_service_bearer(DBusSmsObject *obj,
106 DBusGMethodInvocation *method_context)
108 g_assert(FALSE);
109 return TRUE;
112 gboolean smartphone_sms_set_service_bearer(DBusSmsObject *obj,
113 const gchar *mode,
114 DBusGMethodInvocation *method_context)
116 g_assert(FALSE);
117 return TRUE;
120 gboolean smartphone_sms_send_message(DBusSmsObject *obj,
121 const gchar *message,
122 const gchar *number,
123 const gboolean want_report,
124 DBusGMethodInvocation *method_context)
126 obj->sms->send_message( obj->sms,
127 method_context,
128 message,
129 number,
130 want_report);
131 return TRUE;
135 /*************************Method replies***************************************/
138 void smartphone_sms_send_message_reply(SMSIPCInterface *sms_ipc,
139 gpointer ipc_data)
141 if (ipc_data)
142 dbus_g_method_return((DBusGMethodInvocation*) ipc_data);
146 /*****************Method errors***************************************/
149 void smartphone_sms_send_message_error( SMSIPCInterface *sms_ipc,
150 gpointer ipc_data,
151 GError *error)
153 if (ipc_data)
154 dbus_g_method_return_error((DBusGMethodInvocation*) ipc_data,
155 error);
159 DBusSmsObject *gsmd_dbus_sms_initialize (SMSIPCInterface *sms_ipc,
160 SMSInterface *sms)
162 DBusSmsObject *obj = g_object_new (DBUS_SMS_TYPE_OBJECT, NULL);
163 sms_ipc->priv = obj;
164 obj->sms = sms;
166 //Signals
167 sms_ipc->incoming_message = &smartphone_sms_incoming_message;
168 sms_ipc->message_sent = &smartphone_sms_message_sent;
173 //Method replies
174 sms_ipc->send_message_reply = &smartphone_sms_send_message_reply;
176 //Method errors
177 sms_ipc->send_message_error = &smartphone_sms_send_message_error;
181 return obj;