core cleanup: move code for "copy to" menu to purple backend
[siplcs.git] / src / miranda / miranda-notify.c
blobfd337294c352338b58eb0f2b187449cf73e795e9
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-backend.h"
35 #include "sipe-core.h"
36 #include "miranda-private.h"
38 static void notify_message(struct sipe_core_public *sipe_public,
39 struct sipe_backend_chat_session *backend_session,
40 const gchar *who,
41 const gchar *message,
42 int eventtype,
43 const gchar *prefix
46 SIPPROTO *pr = sipe_public->backend_private;
48 if (backend_session)
50 GCDEST gcd = {0};
51 GCEVENT gce = {0};
52 gchar *msg;
54 gcd.pszModule = pr->proto.m_szModuleName;
55 gcd.pszID = backend_session->conv;
56 gcd.iType = GC_EVENT_INFORMATION;
58 msg = mir_alloc(strlen(message)+strlen(prefix)+1);
59 mir_snprintf(msg, strlen(message)+strlen(prefix)+1, "%s%s", prefix, message);
61 gce.cbSize = sizeof(gce);
62 gce.pDest = &gcd;
63 gce.pszText = msg;
64 // gce.time = mtime; // FIXME: Generate timestamp
66 CallService( MS_GC_EVENT, 0, (LPARAM)&gce );
67 mir_free(msg);
69 } else {
70 HANDLE hContact = sipe_backend_buddy_find( sipe_public, who, NULL );
71 if (hContact)
73 sipe_miranda_AddEvent(pr, hContact, eventtype, time(NULL), DBEF_UTF, strlen(message), (PBYTE)message);
79 void sipe_backend_notify_message_error(struct sipe_core_public *sipe_public,
80 struct sipe_backend_chat_session *backend_session,
81 const gchar *who,
82 const gchar *message)
84 notify_message(sipe_public, backend_session, who, message, SIPE_EVENTTYPE_ERROR_NOTIFY, "Error: ");
87 void sipe_backend_notify_message_info(struct sipe_core_public *sipe_public,
88 struct sipe_backend_chat_session *backend_session,
89 const gchar *who,
90 const gchar *message)
92 notify_message(sipe_public, backend_session, who, message, SIPE_EVENTTYPE_INFO_NOTIFY, "Info: ");
95 void sipe_backend_notify_error(const gchar *title,
96 const gchar *msg)
98 sipe_miranda_msgbox(msg, title);
102 Local Variables:
103 mode: c
104 c-file-style: "bsd"
105 indent-tabs-mode: t
106 tab-width: 8
107 End: