Commit 23fb1217 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#3620] Receive the message on the client side

parent d5a84ba9
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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);
}
}
......
......@@ -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
......
......@@ -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) {
......
......@@ -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
......
......@@ -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 ()));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment