summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2010-01-23 17:31:09 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2010-01-23 17:31:09 +0000
commit395542942d1ab15f62a8fc4eba068f1d9efcff3f (patch)
tree1c362ade01a4fa4283a4bb8210bd550fe7b20e43
parent29224b5cce3353b67784ada08165ff9259a5bee1 (diff)
sip: 0.1.4.0
* Fix for making calls + Added MirVer (were possible) + Added popups to show errors git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@215 c086bb3d-8645-0410-b8da-73a8550f86e7
-rw-r--r--Protocols/SIP/Docs/sip_changelog.txt5
-rw-r--r--Protocols/SIP/Docs/sip_version.txt2
-rw-r--r--Protocols/SIP/SIPProto.cpp130
-rw-r--r--Protocols/SIP/SIPProto.h9
-rw-r--r--Protocols/SIP/commons.h1
-rw-r--r--Protocols/SIP/popup.cpp312
-rw-r--r--Protocols/SIP/popup.h63
-rw-r--r--Protocols/SIP/sip.cpp6
-rw-r--r--Protocols/SIP/sip.vcproj9
9 files changed, 519 insertions, 18 deletions
diff --git a/Protocols/SIP/Docs/sip_changelog.txt b/Protocols/SIP/Docs/sip_changelog.txt
index b8b858f..508cb5c 100644
--- a/Protocols/SIP/Docs/sip_changelog.txt
+++ b/Protocols/SIP/Docs/sip_changelog.txt
@@ -2,6 +2,11 @@ SIP protocol
Changelog:
+. 0.1.4.0
+ * Fix for making calls
+ + Added MirVer (were possible)
+ + Added popups to show errors
+
. 0.1.3.0
* Fix for going online after connecting error
* Fix for reconection crash
diff --git a/Protocols/SIP/Docs/sip_version.txt b/Protocols/SIP/Docs/sip_version.txt
index 7a5d348..77a8c29 100644
--- a/Protocols/SIP/Docs/sip_version.txt
+++ b/Protocols/SIP/Docs/sip_version.txt
@@ -1 +1 @@
-SIP protocol 0.1.3.0 \ No newline at end of file
+SIP protocol 0.1.4.0 \ No newline at end of file
diff --git a/Protocols/SIP/SIPProto.cpp b/Protocols/SIP/SIPProto.cpp
index 2f79e16..df0a005 100644
--- a/Protocols/SIP/SIPProto.cpp
+++ b/Protocols/SIP/SIPProto.cpp
@@ -417,6 +417,9 @@ static void static_on_pager(pjsua_call_id call_id, const pj_str_t *from,
if (proto == NULL)
return;
+ if (!proto->on_pager_sync(call_id, from, to, contact, mime_type, text, rdata))
+ return;
+
SIPEvent ev;
memset(&ev, 0, sizeof(ev));
ev.type = SIPEvent::pager;
@@ -465,6 +468,9 @@ static void static_on_typing(pjsua_call_id call_id, const pj_str_t *from,
if (proto == NULL)
return;
+ if (!proto->on_typing_sync(call_id, from, to, contact, is_typing, rdata))
+ return;
+
SIPEvent ev;
memset(&ev, 0, sizeof(ev));
ev.type = SIPEvent::typing;
@@ -488,7 +494,13 @@ static void static_on_log(int level, const char *data, int len)
{
char tmp[1024];
mir_snprintf(tmp, MAX_REGS(tmp), "Level %d : %*s", level, len, data);
+
+#ifdef _DEBUB
OutputDebugStringA(tmp);
+#endif
+
+ if (instances.getCount() > 0)
+ instances[0].Trace(SipToTchar(pj_str(tmp)));
}
@@ -505,8 +517,7 @@ int SIPProto::Connect()
if (status != PJ_SUCCESS)
{
Error(status, _T("Error creating pjsua"));
- Disconnect();
- return 1;
+ return -1;
}
hasToDestroy = true;
}
@@ -517,9 +528,9 @@ int SIPProto::Connect()
pjsua_config cfg;
pjsua_config_default(&cfg);
-#ifndef DEBUG
- cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
-#endif
+//#ifndef _DEBUG
+// cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
+//#endif
cfg.cb.on_incoming_call = &static_on_incoming_call;
cfg.cb.on_call_media_state = &static_on_call_media_state;
cfg.cb.on_call_state = &static_on_call_state;
@@ -531,6 +542,14 @@ int SIPProto::Connect()
cfg.cb.on_typing2 = &static_on_typing;
cfg.cb.on_mwi_info = &static_on_mwi_info;
+ char mir_ver[1024];
+ CallService(MS_SYSTEM_GETVERSIONTEXT, (WPARAM) sizeof(mir_ver), (LPARAM) mir_ver);
+
+ TCHAR user_agent[1024];
+ mir_sntprintf(user_agent, MAX_REGS(user_agent), _T("Miranda IM %s (pjsua v%s)/%s"),
+ CharToTchar(mir_ver).get(), CharToTchar(pj_get_version()).get(), _T(PJ_OS_NAME));
+ TcharToSip ua(user_agent);
+ cfg.user_agent = pj_str(ua);
if (!IsEmpty(opts.stun.host))
{
@@ -591,8 +610,16 @@ int SIPProto::Connect()
status = pjsua_transport_create(PJSIP_TRANSPORT_TLS, &cfg, &udp_transport_id);
if (status != PJ_SUCCESS)
Error(status, _T("Error creating TLS transport"));
+
+ cfg.port = 4000;
+ status = pjsua_media_transports_create(&cfg);
+ if (status != PJ_SUCCESS)
+ Error(status, _T("Error creating media transports"));
}
+ pjsua_get_snd_dev(&defaultInput, &defaultOutput);
+ pjsua_set_null_snd_dev();
+
{
pj_status_t status = pjsua_start();
if (status != PJ_SUCCESS)
@@ -611,9 +638,10 @@ int SIPProto::Connect()
pjsua_acc_config cfg;
pjsua_acc_config_default(&cfg);
cfg.user_data = this;
-#ifndef DEBUG
- cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
-#endif
+// cfg.transport_id = transport_id;
+//#ifndef _DEBUG
+// cfg.use_srtp = PJMEDIA_SRTP_OPTIONAL;
+//#endif
BuildURI(tmp, MAX_REGS(tmp), opts.username, opts.domain);
TcharToSip id(tmp);
@@ -890,8 +918,14 @@ void SIPProto::ShowMessage(int type, TCHAR *fmt, va_list args)
mir_vsntprintf(&buff[7], MAX_REGS(buff)-7, fmt, args);
+#ifdef _DEBUG
OutputDebugString(buff);
OutputDebugString(_T("\n"));
+#endif
+
+ if (type == MESSAGE_TYPE_ERROR)
+ ShowErrPopup(buff, m_tszUserName);
+
CallService(MS_NETLIB_LOG, (WPARAM) hNetlibUser, (LPARAM) TcharToChar(buff).get());
}
@@ -1125,6 +1159,9 @@ void SIPProto::on_incoming_call(pjsua_call_id call_id)
return;
}
+ // Send 180/RINGING
+ pjsua_call_answer(call_id, 180, NULL, NULL);
+
pjsua_buddy_id buddy_id = pjsua_buddy_find(&info.remote_info);
if (buddy_id != PJSUA_INVALID_ID)
{
@@ -1161,9 +1198,16 @@ void SIPProto::on_call_state(pjsua_call_id call_id, const pjsua_call_info &info)
switch(info.state)
{
- case PJSIP_INV_STATE_NULL:
+/* case PJSIP_INV_STATE_CALLING:
+ case PJSIP_INV_STATE_INCOMING:
+ {
+ ConfigureDevices();
+ break;
+ }
+*/ case PJSIP_INV_STATE_NULL:
case PJSIP_INV_STATE_DISCONNECTED:
{
+ pjsua_set_null_snd_dev();
NotifyCall(call_id, VOICE_STATE_ENDED);
break;
}
@@ -1257,11 +1301,11 @@ void SIPProto::ConfigureDevices()
int input, output;
pjsua_get_snd_dev(&input, &output);
- int expectedInput = GetDevice(false, input);
- int expectedOutput = GetDevice(true, output);
+ int expectedInput = GetDevice(false, defaultInput);
+ int expectedOutput = GetDevice(true, defaultOutput);
if (input != expectedInput || output != expectedOutput)
- pjsua_set_snd_dev(input, output);
+ pjsua_set_snd_dev(expectedInput, expectedOutput);
if (DBGetContactSettingByte(NULL, "VoiceService", "EchoCancelation", TRUE))
pjsua_set_ec(PJSUA_DEFAULT_EC_TAIL_LEN, 0);
@@ -1418,7 +1462,7 @@ int __cdecl SIPProto::VoiceAnswerCall(WPARAM wParam, LPARAM lParam)
return -1;
}
- if (info.state == PJSIP_INV_STATE_INCOMING)
+ if (info.state == PJSIP_INV_STATE_INCOMING || info.state == PJSIP_INV_STATE_EARLY)
{
pj_status_t status = pjsua_call_answer(call_id, 200, NULL, NULL);
if (status != PJ_SUCCESS)
@@ -1755,6 +1799,17 @@ void SIPProto::on_buddy_state(pjsua_buddy_id buddy_id)
}
}
+bool SIPProto::on_pager_sync(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to,
+ const pj_str_t *contact, const pj_str_t *mime_type, const pj_str_t *text, pjsip_rx_data *rdata)
+{
+ HANDLE hContact = GetContact(SipToTchar(*from), true, true);
+ if (hContact == NULL)
+ return false;
+
+ LoadMirVer(hContact, rdata);
+
+ return true;
+}
void SIPProto::on_pager(char *from, char *text, char *mime_type)
{
@@ -1870,6 +1925,23 @@ void SIPProto::on_pager_status(HANDLE hContact, LONG messageID, pjsip_status_cod
}
+bool SIPProto::on_typing_sync(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to,
+ const pj_str_t *contact, pj_bool_t is_typing, pjsip_rx_data *rdata)
+{
+ pjsua_buddy_id buddy_id = pjsua_buddy_find(from);
+ if (buddy_id == PJSUA_INVALID_ID)
+ return false;
+
+ HANDLE hContact = GetContact(buddy_id);
+ if (hContact == NULL)
+ return false;
+
+ LoadMirVer(hContact, rdata);
+
+ return true;
+}
+
+
void SIPProto::on_typing(char *from, bool isTyping)
{
pj_str_t ret;
@@ -1915,6 +1987,27 @@ int __cdecl SIPProto::UserIsTyping(HANDLE hContact, int type)
}
+void SIPProto::LoadMirVer(HANDLE hContact, pjsip_rx_data *rdata)
+{
+ pjsip_hdr *hdr = (pjsip_hdr *) pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &pj_str("User-Agent"), NULL);
+ if (hdr)
+ {
+ char buff[1024];
+ pjsip_hdr_print_on(hdr, buff, MAX_REGS(buff));
+
+ TCHAR mirver[1024];
+ lstrcpyn(mirver, SipToTchar(pj_str(&buff[11])), MAX_REGS(mirver));
+ lstrtrim(mirver);
+
+ DBWriteContactSettingTString(hContact, m_szModuleName, "MirVer", mirver);
+ }
+ else
+ {
+ DBDeleteContactSetting(hContact, m_szModuleName, "MirVer");
+ }
+}
+
+
// Handler for incoming presence subscription request
bool SIPProto::on_incoming_subscribe_sync(pjsua_srv_pres *srv_pres,
pjsua_buddy_id buddy_id,
@@ -1930,7 +2023,16 @@ bool SIPProto::on_incoming_subscribe_sync(pjsua_srv_pres *srv_pres,
return true;
}
- int authState = DBGetContactSettingByte(GetContact(buddy_id), m_szModuleName, "AuthState", 0);
+ HANDLE hContact = GetContact(buddy_id);
+ if (hContact == NULL)
+ {
+ *code = PJSIP_SC_ACCEPTED;
+ return true;
+ }
+
+ LoadMirVer(hContact, rdata);
+
+ int authState = DBGetContactSettingByte(hContact, m_szModuleName, "AuthState", 0);
switch(authState)
{
case AUTH_STATE_AUTHORIZED:
diff --git a/Protocols/SIP/SIPProto.h b/Protocols/SIP/SIPProto.h
index 6efbe59..889d633 100644
--- a/Protocols/SIP/SIPProto.h
+++ b/Protocols/SIP/SIPProto.h
@@ -41,6 +41,7 @@ private:
LONG messageID;
LONG awayMessageID;
TCHAR *awayMessages[ID_STATUS_OUTTOLUNCH - ID_STATUS_ONLINE + 1];
+ int defaultInput, defaultOutput;
public:
struct {
@@ -136,12 +137,18 @@ public:
pjsua_msg_data *msg_data);
void on_incoming_subscribe(char *from, char *text, pjsua_srv_pres *srv_pres);
void on_buddy_state(pjsua_buddy_id buddy_id);
+ bool on_pager_sync(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact,
+ const pj_str_t *mime_type, const pj_str_t *text, pjsip_rx_data *rdata);
void on_pager(char *from, char *text, char *mime_type);
void on_pager_status(HANDLE hContact, LONG messageID, pjsip_status_code status, char *text);
+ bool on_typing_sync(pjsua_call_id call_id, const pj_str_t *from, const pj_str_t *to, const pj_str_t *contact,
+ pj_bool_t is_typing, pjsip_rx_data *rdata);
void on_typing(char *from, bool isTyping);
bool IsMyContact(HANDLE hContact);
+ void Trace(TCHAR *fmt, ...);
+
private:
int ConvertStatus(int status);
void BroadcastStatus(int newStatus);
@@ -157,7 +164,6 @@ private:
int __cdecl OnPreShutdown(WPARAM wParam, LPARAM lParam);
int __cdecl OnContactDeleted(WPARAM wParam, LPARAM lParam);
- void Trace(TCHAR *fmt, ...);
void Info(TCHAR *fmt, ...);
void Error(TCHAR *fmt, ...);
void Error(pj_status_t status, TCHAR *fmt, ...);
@@ -194,6 +200,7 @@ private:
HANDLE GetContact(const TCHAR *uri, bool addIfNeeded = false, bool temporary = false);
void Attach(HANDLE hContact, pjsua_buddy_id buddy_id);
void __cdecl FakeMsgAck(void *param);
+ void LoadMirVer(HANDLE hContact, pjsip_rx_data *rdata);
// Away messages
void __cdecl GetAwayMsgThread(void* arg);
diff --git a/Protocols/SIP/commons.h b/Protocols/SIP/commons.h
index c767ffd..8ad7689 100644
--- a/Protocols/SIP/commons.h
+++ b/Protocols/SIP/commons.h
@@ -81,6 +81,7 @@ Boston, MA 02111-1307, USA.
#include "resource.h"
#include "strutils.h"
+#include "popup.h"
struct MessageData
diff --git a/Protocols/SIP/popup.cpp b/Protocols/SIP/popup.cpp
new file mode 100644
index 0000000..9a10593
--- /dev/null
+++ b/Protocols/SIP/popup.cpp
@@ -0,0 +1,312 @@
+/*
+Copyright (C) 2005-2010 Ricardo Pescuma Domenecci
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+
+#include "commons.h"
+
+
+
+// Prototypes /////////////////////////////////////////////////////////////////////////////////////
+
+#define WMU_ACTION (WM_USER + 1)
+
+
+LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+HWND hPopupWindow = NULL;
+
+
+static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+
+
+// Functions //////////////////////////////////////////////////////////////////////////////////////
+
+
+// Initializations needed by popups
+void InitPopups()
+{
+ // window needed for popup commands
+ hPopupWindow = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), _T(MODULE_NAME) _T("_PopupWindow"),
+ 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP,
+ NULL, hInst, NULL);
+ SetWindowLong(hPopupWindow, GWL_WNDPROC, (LONG)(WNDPROC)PopupWndProc);
+}
+
+
+// Deinitializations needed by popups
+void DeInitPopups()
+{
+}
+
+
+// Show an error popup
+void ShowErrPopup(const TCHAR *description, const TCHAR *title)
+{
+ ShowPopupEx(NULL, title == NULL ? _T(MODULE_NAME) _T(" Error") : title, description,
+ NULL, POPUP_TYPE_ERROR, NULL);
+}
+
+
+void ShowTestPopup(const TCHAR *title, const TCHAR *description, const Options *op)
+{
+ ShowPopupEx(NULL, title, description, NULL, POPUP_TYPE_TEST, op);
+}
+
+
+void ShowPopup(HANDLE hContact, const TCHAR *title, const TCHAR *description)
+{
+ ShowPopupEx(hContact, title, description, hContact, POPUP_TYPE_NORMAL, NULL);
+}
+
+
+// Show an popup
+void ShowPopupEx(HANDLE hContact, const TCHAR *title, const TCHAR *description,
+ void *plugin_data, int type, const Options *op)
+{
+#ifdef UNICODE
+ if(ServiceExists(MS_POPUP_ADDPOPUPW))
+ {
+ // Make popup
+ POPUPDATAW ppd;
+
+ ZeroMemory(&ppd, sizeof(ppd));
+ ppd.lchContact = hContact;
+ ppd.lchIcon = (HICON) LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(174),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ if (title != NULL)
+ lstrcpyn(ppd.lpwzContactName, title, MAX_REGS(ppd.lpwzContactName));
+ else if (hContact != NULL)
+ lstrcpyn(ppd.lpwzContactName, (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR),
+ MAX_REGS(ppd.lpwzContactName));
+
+ if (description != NULL)
+ lstrcpyn(ppd.lpwzText, description, MAX_REGS(ppd.lpwzText));
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+/* if (op->popup_use_default_colors)
+ {
+ ppd.colorBack = 0;
+ ppd.colorText = 0;
+ }
+ else if (op->popup_use_win_colors)
+ {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ else
+ {
+ ppd.colorBack = op->popup_bkg_color;
+ ppd.colorText = op->popup_text_color;
+ }
+*/ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.colorBack = RGB(200,0,0);
+ ppd.colorText = RGB(255,255,255);
+ }
+
+ if (type == POPUP_TYPE_NORMAL)
+ {
+ ppd.PluginWindowProc = PopupDlgProc;
+ ppd.PluginData = plugin_data;
+ }
+ else // if (type == POPUP_TYPE_TEST || type == POPUP_TYPE_ERROR)
+ {
+ ppd.PluginWindowProc = DumbPopupDlgProc;
+ }
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+/* switch (op->popup_delay_type)
+ {
+ case POPUP_DELAY_CUSTOM:
+ ppd.iSeconds = opts.popup_timeout;
+ break;
+
+ case POPUP_DELAY_PERMANENT:
+ ppd.iSeconds = -1;
+ break;
+
+ //case POPUP_DELAY_DEFAULT:
+ default:
+ ppd.iSeconds = 0;
+ break;
+ }
+*/ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.iSeconds = 0;
+ }
+
+ // Now that every field has been filled, we want to see the popup.
+ CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&ppd,0);
+ }
+ else
+#endif
+ if(ServiceExists(MS_POPUP_ADDPOPUPEX))
+ {
+ // Make popup
+ POPUPDATAEX ppd;
+
+ ZeroMemory(&ppd, sizeof(ppd));
+ ppd.lchContact = hContact;
+ ppd.lchIcon = (HICON) LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(174),IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
+
+ if (title != NULL)
+ lstrcpynA(ppd.lpzContactName, TcharToChar(title), MAX_REGS(ppd.lpzContactName));
+ else
+ lstrcpynA(ppd.lpzContactName, (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0),
+ MAX_REGS(ppd.lpzContactName));
+
+ if (description != NULL)
+ lstrcpynA(ppd.lpzText, TcharToChar(description), MAX_REGS(ppd.lpzText));
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+/* if (op->popup_use_default_colors)
+ {
+ ppd.colorBack = 0;
+ ppd.colorText = 0;
+ }
+ else if (op->popup_use_win_colors)
+ {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ else
+ {
+ ppd.colorBack = op->popup_bkg_color;
+ ppd.colorText = op->popup_text_color;
+ }
+*/
+ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.colorBack = RGB(200,0,0);
+ ppd.colorText = RGB(255,255,255);
+ }
+
+ if (type == POPUP_TYPE_NORMAL)
+ {
+ ppd.PluginWindowProc = PopupDlgProc;
+ ppd.PluginData = plugin_data;
+ }
+ else // if (type == POPUP_TYPE_TEST || type == POPUP_TYPE_ERROR)
+ {
+ ppd.PluginWindowProc = DumbPopupDlgProc;
+ }
+
+ if (type == POPUP_TYPE_NORMAL || type == POPUP_TYPE_TEST)
+ {
+/* switch (op->popup_delay_type)
+ {
+ case POPUP_DELAY_CUSTOM:
+ ppd.iSeconds = opts.popup_timeout;
+ break;
+
+ case POPUP_DELAY_PERMANENT:
+ ppd.iSeconds = -1;
+ break;
+
+ //case POPUP_DELAY_DEFAULT:
+ default:
+ ppd.iSeconds = 0;
+ break;
+ }
+*/ }
+ else // if (type == POPUP_TYPE_ERROR)
+ {
+ ppd.iSeconds = 0;
+ }
+
+ // Now that every field has been filled, we want to see the popup.
+ CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd,0);
+ }
+}
+
+
+// Handle to the hidden windows to handle actions for popup clicks
+// wParam has the number of MOTD in case of WMU_SHOW_MOTD_DETAILS
+LRESULT CALLBACK PopupWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg == WMU_ACTION)
+ {
+ }
+ return DefWindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
+// Handle to popup events
+static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message) {
+ case WM_COMMAND:
+ {
+ SendMessage(hPopupWindow, WMU_ACTION, (WPARAM)PUGetPluginData(hWnd), 0);
+ PUDeletePopUp(hWnd);
+
+ return TRUE;
+ }
+
+ case WM_CONTEXTMENU:
+ {
+ SendMessage(hPopupWindow, WMU_ACTION, (WPARAM)PUGetPluginData(hWnd), 0);
+ PUDeletePopUp(hWnd);
+
+ return TRUE;
+ }
+
+ case UM_FREEPLUGINDATA:
+ {
+ return TRUE;
+ }
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+
+// Handle to popup events
+static LRESULT CALLBACK DumbPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message) {
+ case WM_COMMAND:
+ {
+ PUDeletePopUp(hWnd);
+ return TRUE;
+ }
+
+ case WM_CONTEXTMENU:
+ {
+ PUDeletePopUp(hWnd);
+ return TRUE;
+ }
+
+ case UM_FREEPLUGINDATA:
+ {
+ return TRUE;
+ }
+ }
+
+ return DefWindowProc(hWnd, message, wParam, lParam);
+}
+
diff --git a/Protocols/SIP/popup.h b/Protocols/SIP/popup.h
new file mode 100644
index 0000000..3a97b08
--- /dev/null
+++ b/Protocols/SIP/popup.h
@@ -0,0 +1,63 @@
+/*
+Copyright (C) 2005-2010 Ricardo Pescuma Domenecci
+
+This is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with this file; see the file license.txt. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.
+*/
+
+
+#ifndef __POPUP_H__
+# define __POPUP_H__
+
+#include "commons.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+typedef void * Options;
+
+
+// Initializations needed by popups
+void InitPopups();
+
+// Deinitializations needed by popups
+void DeInitPopups();
+
+
+#define POPUP_TYPE_NORMAL 0
+#define POPUP_TYPE_TEST 1
+#define POPUP_TYPE_ERROR 2
+
+// Show an popup
+void ShowPopup(HANDLE hContact, const TCHAR *title, const TCHAR *description);
+
+// Show an test
+void ShowTestPopup(const TCHAR *title, const TCHAR *description, const Options *op);
+
+// Show an error popup
+void ShowErrPopup(const TCHAR *description, const TCHAR *title = NULL);
+
+void ShowPopupEx(HANDLE hContact, const TCHAR *title, const TCHAR *description,
+ void *plugin_data, int type, const Options *op);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __POPUP_H__
diff --git a/Protocols/SIP/sip.cpp b/Protocols/SIP/sip.cpp
index c68b538..d1cf3ac 100644
--- a/Protocols/SIP/sip.cpp
+++ b/Protocols/SIP/sip.cpp
@@ -30,7 +30,7 @@ PLUGININFOEX pluginInfo={
#else
"SIP protocol (Ansi)",
#endif
- PLUGIN_MAKE_VERSION(0,1,3,0),
+ PLUGIN_MAKE_VERSION(0,1,4,0),
"Provides support for SIP protocol",
"Ricardo Pescuma Domenecci",
"pescuma@miranda-im.org",
@@ -250,12 +250,16 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam)
CallService(MS_UPDATE_REGISTER, 0, (LPARAM)&upd);
}
+ InitPopups();
+
return 0;
}
int PreShutdown(WPARAM wParam, LPARAM lParam)
{
+ DeInitPopups();
+
for(unsigned int i = 0; i < hHooks.size(); ++i)
UnhookEvent(hHooks[i]);
diff --git a/Protocols/SIP/sip.vcproj b/Protocols/SIP/sip.vcproj
index ddb8396..6825be3 100644
--- a/Protocols/SIP/sip.vcproj
+++ b/Protocols/SIP/sip.vcproj
@@ -58,7 +58,6 @@
AssemblerListingLocation=".\Unicode_Release/"
ObjectFile=".\Unicode_Release/"
ProgramDataBaseFileName=".\Unicode_Release/"
- BrowseInformation="2"
BrowseInformationFile=".\Unicode_Release/"
WarningLevel="3"
SuppressStartupBanner="true"
@@ -445,6 +444,10 @@
>
</File>
<File
+ RelativePath=".\popup.h"
+ >
+ </File>
+ <File
RelativePath="resource.h"
>
</File>
@@ -627,6 +630,10 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\popup.cpp"
+ >
+ </File>
+ <File
RelativePath="sip.cpp"
>
<FileConfiguration