clientops.c

Go to the documentation of this file.
00001 /* OpenSER PURPLE MODULE
00002  * 
00003  * Copyright (C) 2008 Atos Worldline
00004  * Contact: Eric PTAK <eric.ptak@atosorigin.com>
00005  *
00006  * This program is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018  *
00019  */
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <libpurple/conversation.h>
00023 
00024 #include "../../dprint.h"
00025 #include "../../mem/mem.h"
00026 
00027 #include "clientops.h"
00028 #include "purple.h"
00029 #include "purple_sip.h"
00030 #include "mapping.h"
00031 
00032 void write_conv(PurpleConversation *conv, const char *who, const char *alias, const char *message, PurpleMessageFlags flags, time_t mtime) {
00033    char *sip_to, *sip_from;
00034    purple_conversation_clear_message_history(conv);
00035    if (flags == PURPLE_MESSAGE_RECV) {
00036       LM_DBG("IM received from <%s> to <%s>\n", who, conv->account->username);
00037       sip_to = find_sip_user(conv->account->username);
00038       if (sip_to == NULL) {
00039          LM_DBG("cannot retrieve sip uri for <%s>\n", conv->account->username);
00040          return;
00041       }
00042       LM_DBG("<%s> translated to <%s>\n", conv->account->username, sip_to);
00043 
00044       sip_from = find_sip_user((char*) who);
00045       if (sip_from == NULL) {
00046          LM_DBG("cannot retrieve sip uri for <%s>\n", who);
00047          pkg_free(sip_to);
00048          return;
00049       }
00050       LM_DBG("<%s> translated to <%s>\n", who, sip_from);
00051       
00052       LM_DBG("sending sip message\n");
00053       if (purple_send_sip_msg(sip_to, sip_from, (char*) message) < 0)
00054          LM_ERR("error sending sip message\n");
00055       
00056       pkg_free(sip_to);
00057       pkg_free(sip_from);
00058    }
00059 }
00060 
00061 

Generated on Mon May 21 18:00:25 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6