clientops.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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