media: fix relay-info with Farstream 0.2
[siplcs.git] / src / miranda / miranda-notify.c
blobbf19e63f3fad21adb5438fee7ec4d8387bfa0a16
1 /**
2 * @file miranda-notify.c
4 * pidgin-sipe
6 * Copyright (C) 2010-11 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <windows.h>
24 #include <stdio.h>
26 #include <glib.h>
28 #include "newpluginapi.h"
29 #include "m_protosvc.h"
30 #include "m_protoint.h"
31 #include "m_chat.h"
32 #include "m_database.h"
34 #include "sipe-common.h"
35 #include "sipe-backend.h"
36 #include "sipe-core.h"
37 #include "miranda-private.h"
39 static void notify_message(struct sipe_core_public *sipe_public,
40 struct sipe_backend_chat_session *backend_session,
41 const gchar *who,
42 const gchar *message,
43 int eventtype,
44 const gchar *prefix
47 SIPPROTO *pr = sipe_public->backend_private;
49 if (backend_session)
51 GCDEST gcd = {0};
52 GCEVENT gce = {0};
53 gchar *msg;
55 gcd.pszModule = pr->proto.m_szModuleName;
56 gcd.pszID = backend_session->conv;
57 gcd.iType = GC_EVENT_INFORMATION;
59 msg = mir_alloc(strlen(message)+strlen(prefix)+1);
60 mir_snprintf(msg, strlen(message)+strlen(prefix)+1, "%s%s", prefix, message);
62 gce.cbSize = sizeof(gce);
63 gce.pDest = &gcd;
64 gce.pszText = msg;
65 // gce.time = mtime; // FIXME: Generate timestamp
67 CallService( MS_GC_EVENT, 0, (LPARAM)&gce );
68 mir_free(msg);
70 } else {
71 HANDLE hContact = sipe_backend_buddy_find( sipe_public, who, NULL );
72 if (hContact)
74 sipe_miranda_AddEvent(pr, hContact, eventtype, time(NULL), DBEF_UTF, strlen(message), (PBYTE)message);
80 void sipe_backend_notify_message_error(struct sipe_core_public *sipe_public,
81 struct sipe_backend_chat_session *backend_session,
82 const gchar *who,
83 const gchar *message)
85 notify_message(sipe_public, backend_session, who, message, SIPE_EVENTTYPE_ERROR_NOTIFY, "Error: ");
88 void sipe_backend_notify_message_info(struct sipe_core_public *sipe_public,
89 struct sipe_backend_chat_session *backend_session,
90 const gchar *who,
91 const gchar *message)
93 notify_message(sipe_public, backend_session, who, message, SIPE_EVENTTYPE_INFO_NOTIFY, "Info: ");
96 void sipe_backend_notify_error(SIPE_UNUSED_PARAMETER struct sipe_core_public *sipe_public,
97 const gchar *title,
98 const gchar *msg)
100 sipe_miranda_msgbox(msg, title);
104 Local Variables:
105 mode: c
106 c-file-style: "bsd"
107 indent-tabs-mode: t
108 tab-width: 8
109 End: