diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index a5273a2ee07f01d5f1b6c76d593646535d5ac459..15977c49ff0c7cd4149086e002f027b233be3c34 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -120,11 +120,11 @@ voice_mail_cb(DBusGProxy *proxy UNUSED, const gchar* accountID, const guint nb, } static void -incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar* accountID UNUSED, +incoming_message_cb(DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const gchar* msg, void * foo UNUSED ) { - DEBUG ("Message %s!",msg); - + DEBUG ("Message %s!",msg); + notify_incoming_message (callID, msg); } static void diff --git a/sflphone-client-gnome/src/sflnotify.c b/sflphone-client-gnome/src/sflnotify.c index 5ac960e0035e7a08de0eddfed880998281e3b8b7..32a529d77efd91d59bb809844721dd983b070277 100644 --- a/sflphone-client-gnome/src/sflnotify.c +++ b/sflphone-client-gnome/src/sflnotify.c @@ -67,6 +67,24 @@ void create_new_gnome_notification (gchar *title, gchar *body, NotifyUrgency urg } } + void +notify_incoming_message (const gchar *callID, const gchar *msg) +{ + + gchar* text; + gchar* title; + + title = g_markup_printf_escaped(_("New message")); + text = g_markup_printf_escaped (_("%s says: %s"), callID, msg); + + create_new_gnome_notification (title, + text, + NOTIFY_URGENCY_CRITICAL, + (g_strcasecmp(__TIMEOUT_MODE, "default") == 0 )? __TIMEOUT_TIME : NOTIFY_EXPIRES_NEVER, + &_gnome_notification); +} + + void notify_incoming_call (callable_obj_t* c) diff --git a/sflphone-client-gnome/src/sflnotify.h b/sflphone-client-gnome/src/sflnotify.h index 71cfc916658ef94a196d8c9f5d2d2e2a9181e732..8734abec03cd3ba19748ad9ff760697e102e2c4b 100644 --- a/sflphone-client-gnome/src/sflnotify.h +++ b/sflphone-client-gnome/src/sflnotify.h @@ -62,6 +62,13 @@ void free_notification (GnomeNotification *g); */ void notify_incoming_call( callable_obj_t* c); +/** + * Notify an incoming text message + * A dialog box is attached to the status icon + * @param c The incoming message + */ +void notify_incoming_message (const gchar *callID, const gchar *msg); + /** * Notify voice mails count * An info box is attached to the status icon diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index da9bbcf51f4c5b0d39c2541c9d25035863727533..41c9677e82c85055ec4676ff07b663422d236f88 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1611,11 +1611,12 @@ bool ManagerImpl::incomingCall (Call* call, const AccountID& accountId) { return true; } + //THREAD=VoIP -void ManagerImpl::incomingMessage (const AccountID& accountId, +void ManagerImpl::incomingMessage (const CallID& callID, const std::string& message) { if (_dbus) { - _dbus->getCallManager()->incomingMessage(accountId, message); + _dbus->getCallManager()->incomingMessage (callID, message); } } diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 700bb1721d5a906a7df5d8112f9ece9fe251728d..5a42426d440dbc7b5aa3b9d4200051841c5e38cf 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -398,7 +398,7 @@ class ManagerImpl { * @param accountId The account identifier * @param message The content of the message */ - void incomingMessage(const AccountID& accountId, const std::string& message); + void incomingMessage(const CallID& callId, const std::string& message); /** * Notify the client he has voice mails diff --git a/sflphone-common/src/sip/im/InstantMessaging.cpp b/sflphone-common/src/sip/im/InstantMessaging.cpp index b42f5ae8aa0ca3c939cdd043b34680905df3cf21..691ef6e87727e147a08e98cca92d971ce4cc0b49 100644 --- a/sflphone-common/src/sip/im/InstantMessaging.cpp +++ b/sflphone-common/src/sip/im/InstantMessaging.cpp @@ -13,13 +13,26 @@ namespace sfl { return PJ_SUCCESS; } - pj_status_t InstantMessaging::receive (std::string message, CallID& id) { + std::string InstantMessaging::receive (std::string message, CallID& id) { // We just receive a TEXT message. Before sent it to the recipient, we must assure that the message is complete. // We should use a queue to push these messages in + _debug ("New message : %s", message.c_str ()); + + // TODO Archive the messages + // TODO Security check + // TODO String cleaning + + return message; + } + pj_status_t InstantMessaging::notify (CallID& id) { + + // Notify the clients through a D-Bus signal + + } pj_status_t InstantMessaging::send (pjsip_inv_session *session, const std::string& text) { diff --git a/sflphone-common/src/sip/im/InstantMessaging.h b/sflphone-common/src/sip/im/InstantMessaging.h index 78749c742399cb6cff238412b6dd62d4df0110d1..3c9acecbfd4554364b4e197ec08f4e9e3e823a01 100644 --- a/sflphone-common/src/sip/im/InstantMessaging.h +++ b/sflphone-common/src/sip/im/InstantMessaging.h @@ -43,7 +43,7 @@ namespace sfl { * @param message The message contained in the TEXT message * @param id The call recipient of the message */ - pj_status_t receive (std::string message, CallID& id); + std::string receive (std::string message, CallID& id); /* * Send a SIP string message inside a call diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index afdfdde80fdd81f9e2f1f9774d475cd50b561234..75da8298e7b3a0417d15def3ef782feba0f2fbbf 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -3409,8 +3409,11 @@ void call_on_tsx_changed (pjsip_inv_session *inv, pjsip_transaction *tsx, pjsip_ pjsip_dlg_create_response (inv->dlg, r_data, PJSIP_SC_OK, NULL, &t_data); pjsip_dlg_send_response (inv->dlg, tsx, t_data); - imModule->receive (message, call->getCallId ()); - + // Pass through the instant messaging module if needed + // Right now, it does do anything. + // And notify the clients + Manager::instance ().incomingMessage ( call->getCallId (), + imModule->receive (message, call->getCallId ())); }