summaryrefslogtreecommitdiff
path: root/Protocols/IAX
diff options
context:
space:
mode:
Diffstat (limited to 'Protocols/IAX')
-rw-r--r--Protocols/IAX/IAXProto.cpp421
-rw-r--r--Protocols/IAX/IAXProto.h125
-rw-r--r--Protocols/IAX/commons.h4
-rw-r--r--Protocols/IAX/iax.cpp187
-rw-r--r--Protocols/IAX/iax.dsp8
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libgsm.libbin139818 -> 139818 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libiax2.libbin263548 -> 284956 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libiaxclient.libbin2102974 -> 2124852 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libogg.libbin65558 -> 65558 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libportaudio.libbin396496 -> 396496 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libportmixer.libbin45542 -> 45542 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Debug/libspeex.libbin634058 -> 634058 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libgsm.libbin49314 -> 49314 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libiax2.libbin129474 -> 129474 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libiaxclient.libbin822558 -> 822788 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libogg.libbin29444 -> 29444 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libportaudio.libbin141138 -> 141138 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libportmixer.libbin15066 -> 15066 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/Release/libspeex.libbin294770 -> 294770 bytes
-rw-r--r--Protocols/IAX/lib/iaxclient/iaxclient.h5
-rw-r--r--Protocols/IAX/resource.h6
-rw-r--r--Protocols/IAX/resource.rc62
22 files changed, 584 insertions, 234 deletions
diff --git a/Protocols/IAX/IAXProto.cpp b/Protocols/IAX/IAXProto.cpp
new file mode 100644
index 0000000..6c11359
--- /dev/null
+++ b/Protocols/IAX/IAXProto.cpp
@@ -0,0 +1,421 @@
+/*
+Copyright (C) 2009 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"
+
+
+static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static int static_iaxc_callback(iaxc_event e, void *param);
+
+
+IAXProto::IAXProto(const char *aProtoName, const TCHAR *aUserName)
+{
+ InitializeCriticalSection(&cs);
+
+ reg_id = 0;
+ m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
+
+ m_tszUserName = mir_tstrdup(aUserName);
+ m_szProtoName = mir_strdup(aProtoName);
+ m_szModuleName = mir_strdup(aProtoName);
+
+ TCHAR buffer[MAX_PATH];
+ mir_sntprintf(buffer, MAX_REGS(buffer), TranslateT("%s plugin connections"), m_tszUserName);
+
+ NETLIBUSER nl_user = {0};
+ nl_user.cbSize = sizeof(nl_user);
+ nl_user.flags = NUF_OUTGOING | NUF_TCHAR;
+ nl_user.szSettingsModule = m_szModuleName;
+ nl_user.ptszDescriptiveName = buffer;
+ hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
+
+ CreateProtoService(PS_CREATEACCMGRUI, &IAXProto::CreateAccMgrUI);
+
+ static OptPageControl ctrls[] = {
+ { NULL, CONTROL_TEXT, IDC_HOST, "Host", NULL, 0, 0, 256 },
+ { NULL, CONTROL_INT, IDC_PORT, "Port", 4569, 0, 1 },
+ { NULL, CONTROL_TEXT, IDC_USERNAME, "Username", NULL, 0, 0, 16 },
+ { NULL, CONTROL_PASSWORD, IDC_PASSWORD, "Password", NULL, 0, 0, 16 },
+ { NULL, CONTROL_CHECKBOX, IDC_SAVEPASSWORD, "SavePassword", (BYTE) TRUE },
+ };
+
+ memmove(accountManagerCtrls, ctrls, sizeof(accountManagerCtrls));
+ accountManagerCtrls[0].var = &opts.host;
+ accountManagerCtrls[1].var = &opts.port;
+ accountManagerCtrls[2].var = &opts.username;
+ accountManagerCtrls[3].var = &opts.password;
+ accountManagerCtrls[4].var = &opts.savePassword;
+
+ LoadOpts(accountManagerCtrls, MAX_REGS(accountManagerCtrls), m_szModuleName);
+
+ iaxc_set_event_callback(&static_iaxc_callback, this);
+
+ // TODO Handle network out port
+ iaxc_set_preferred_source_udp_port(-1);
+ if (iaxc_initialize(3))
+ throw "!!";
+
+ iaxc_set_formats(IAXC_FORMAT_SPEEX,
+ IAXC_FORMAT_ULAW|IAXC_FORMAT_ALAW|IAXC_FORMAT_GSM|IAXC_FORMAT_SPEEX|IAXC_FORMAT_ILBC);
+ iaxc_set_speex_settings(1,-1,-1,0,8000,3);
+ iaxc_set_silence_threshold(-99);
+
+ if (iaxc_start_processing_thread())
+ throw "!!";
+}
+
+
+IAXProto::~IAXProto()
+{
+ iaxc_stop_processing_thread();
+
+ iaxc_shutdown();
+
+ Netlib_CloseHandle(hNetlibUser);
+
+ mir_free(m_tszUserName);
+ mir_free(m_szProtoName);
+ mir_free(m_szModuleName);
+
+ DeleteCriticalSection(&cs);
+}
+
+
+DWORD_PTR __cdecl IAXProto::GetCaps( int type, HANDLE hContact )
+{
+ switch(type)
+ {
+ case PFLAGNUM_1:
+ return 0;
+
+ case PFLAGNUM_2:
+ return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND
+ | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE | PF2_INVISIBLE | PF2_IDLE;
+
+ case PFLAGNUM_3:
+ return 0;
+
+ case PFLAGNUM_4:
+ return PF4_NOCUSTOMAUTH;
+
+ case PFLAG_UNIQUEIDTEXT:
+ return NULL;
+
+ case PFLAG_UNIQUEIDSETTING:
+ return NULL;
+
+ case PFLAG_MAXLENOFMESSAGE:
+ return 100;
+ }
+
+ return 0;
+}
+
+
+int __cdecl IAXProto::SetStatus( int iNewStatus )
+{
+ if (m_iStatus == iNewStatus)
+ return 0;
+ m_iDesiredStatus = iNewStatus;
+
+ if (m_iDesiredStatus == ID_STATUS_OFFLINE)
+ {
+ Disconnect();
+ }
+ else if (m_iStatus == ID_STATUS_OFFLINE)
+ {
+ BroadcastStatus(ID_STATUS_CONNECTING);
+
+ TCHAR server_port[1024];
+ mir_sntprintf(server_port, MAX_REGS(server_port), _T("%s:%d"), opts.host, opts.port);
+
+ reg_id = iaxc_register(TcharToUtf8(opts.username), opts.password, TcharToUtf8(server_port));
+ if (reg_id <= 0)
+ {
+ BroadcastStatus(ID_STATUS_OFFLINE);
+ return -1;
+ }
+ }
+ else if (m_iStatus > ID_STATUS_OFFLINE)
+ {
+ BroadcastStatus(m_iDesiredStatus);
+ }
+
+ return 0;
+}
+
+
+INT_PTR __cdecl IAXProto::CreateAccMgrUI(WPARAM wParam, LPARAM lParam)
+{
+ return (INT_PTR) CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ACCMGRUI),
+ (HWND) lParam, DlgProcAccMgrUI, (LPARAM)this);
+}
+
+
+void IAXProto::BroadcastStatus(int newStatus)
+{
+ int oldStatus = m_iStatus;
+ m_iStatus = newStatus;
+ SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
+}
+
+
+void IAXProto::CreateProtoService(const char* szService, IAXServiceFunc serviceProc)
+{
+ char str[MAXMODULELABELLENGTH];
+
+ mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
+ ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
+}
+
+
+void IAXProto::CreateProtoService(const char* szService, IAXServiceFuncParam serviceProc, LPARAM lParam)
+{
+ char str[MAXMODULELABELLENGTH];
+ mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
+ ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
+}
+
+
+HANDLE IAXProto::CreateProtoEvent(const char* szService)
+{
+ char str[MAXMODULELABELLENGTH];
+ mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
+ return ::CreateHookableEvent(str);
+}
+
+
+int IAXProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
+{
+ ACKDATA ack = {0};
+ ack.cbSize = sizeof(ACKDATA);
+ ack.szModule = m_szModuleName;
+ ack.hContact = hContact;
+ ack.type = type;
+ ack.result = result;
+ ack.hProcess = hProcess;
+ ack.lParam = lParam;
+ return CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
+}
+
+
+void IAXProto::ShowMessage(bool error, TCHAR *fmt, ...)
+{
+ va_list args;
+ va_start(args, fmt);
+
+ TCHAR buff[1024];
+ mir_sntprintf(buff, MAX_REGS(buff), fmt, args);
+
+ OutputDebugString(buff);
+ CallService(MS_NETLIB_LOG, (WPARAM) hNetlibUser, (LPARAM) (const char *) TcharToChar(buff));
+
+ va_end(args);
+}
+
+
+void IAXProto::Disconnect()
+{
+ iaxc_dump_all_calls();
+
+ if (reg_id > 0)
+ {
+ iaxc_unregister(reg_id);
+ reg_id = 0;
+ }
+
+ BroadcastStatus(ID_STATUS_OFFLINE);
+}
+
+
+int IAXProto::levels_callback(iaxc_ev_levels &levels)
+{
+ return 0;
+}
+
+
+int IAXProto::text_callback(iaxc_ev_text &text)
+{
+ switch(text.type)
+ {
+ case IAXC_TEXT_TYPE_STATUS:
+ {
+ ShowMessage(false, TranslateT("Status: %s"), Utf8ToTchar(text.message));
+ return 1;
+ }
+ case IAXC_TEXT_TYPE_NOTICE:
+ {
+ ShowMessage(false, TranslateT("Notice: %s"), Utf8ToTchar(text.message));
+ return 1;
+ }
+ case IAXC_TEXT_TYPE_ERROR:
+ {
+ ShowMessage(true, Utf8ToTchar(text.message));
+ return 1;
+ }
+ case IAXC_TEXT_TYPE_FATALERROR:
+ {
+ ShowMessage(true, TranslateT("Fatal: %s"), Utf8ToTchar(text.message));
+ Disconnect();
+ return 1;
+ }
+ case IAXC_TEXT_TYPE_IAX:
+ {
+ ShowMessage(false, TranslateT("IAX: %s"), Utf8ToTchar(text.message));
+ return 1;
+ }
+ default:
+ return 0;
+ }
+
+ return 0;
+}
+
+
+int IAXProto::state_callback(iaxc_ev_call_state &call)
+{
+ return 0;
+}
+
+
+int IAXProto::netstats_callback(iaxc_ev_netstats &netstats)
+{
+ return 0;
+}
+
+
+int IAXProto::url_callback(iaxc_ev_url &url)
+{
+ return 0;
+}
+
+
+int IAXProto::registration_callback(iaxc_ev_registration &reg)
+{
+ if (reg.id != reg_id)
+ return 0;
+
+ switch(reg.reply)
+ {
+ case IAXC_REGISTRATION_REPLY_ACK:
+ {
+ BroadcastStatus(m_iDesiredStatus > ID_STATUS_OFFLINE ? m_iDesiredStatus : ID_STATUS_ONLINE);
+
+ if (reg.msgcount > 0)
+ ShowMessage(false, TranslateT("You have %d voicemail message(s)."), reg.msgcount);
+
+ return 1;
+ }
+ case IAXC_REGISTRATION_REPLY_REJ:
+ {
+ ShowMessage(true, TranslateT("Registration rejected"));
+ Disconnect();
+
+ return 1;
+ }
+ case IAXC_REGISTRATION_REPLY_TIMEOUT:
+ {
+ ShowMessage(true, TranslateT("Registration timeout"));
+ Disconnect();
+
+ return 1;
+ }
+ default:
+ return 0;
+ }
+}
+
+
+int IAXProto::iaxc_callback(iaxc_event &e)
+{
+ switch(e.type)
+ {
+ case IAXC_EVENT_LEVELS: return levels_callback(e.ev.levels);
+ case IAXC_EVENT_TEXT: return text_callback(e.ev.text);
+ case IAXC_EVENT_STATE: return state_callback(e.ev.call);
+ case IAXC_EVENT_NETSTAT: return netstats_callback(e.ev.netstats);
+ case IAXC_EVENT_URL: return url_callback(e.ev.url);
+ case IAXC_EVENT_REGISTRATION: return registration_callback(e.ev.reg);
+ default: return 0; // not handled
+ }
+}
+
+
+static void CALLBACK ProcessIAXEvents(void *param)
+{
+ for(int i = 0; i < instances.getCount(); ++i)
+ {
+ IAXProto *proto = &instances[i];
+
+ EnterCriticalSection(&proto->cs);
+
+ for(std::vector<iaxc_event>::iterator it = proto->events.begin(); it != proto->events.end(); ++it)
+ proto->iaxc_callback(*it);
+
+ proto->events.clear();
+
+ LeaveCriticalSection(&proto->cs);
+ }
+}
+
+
+static int static_iaxc_callback(iaxc_event e, void *param)
+{
+ IAXProto *proto = (IAXProto *) param;
+
+ EnterCriticalSection(&proto->cs);
+ proto->events.push_back(e);
+ LeaveCriticalSection(&proto->cs);
+
+ CallFunctionAsync(&ProcessIAXEvents, NULL);
+
+ return 0;
+}
+
+
+
+static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ IAXProto *proto = (IAXProto *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
+ proto = (IAXProto *) lParam;
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
+ {
+ }
+ break;
+ }
+ }
+
+ if (proto == NULL)
+ return FALSE;
+
+ return SaveOptsDlgProc(proto->accountManagerCtrls, MAX_REGS(proto->accountManagerCtrls),
+ proto->m_szModuleName, hwnd, msg, wParam, lParam);
+}
+
diff --git a/Protocols/IAX/IAXProto.h b/Protocols/IAX/IAXProto.h
new file mode 100644
index 0000000..32d0ad8
--- /dev/null
+++ b/Protocols/IAX/IAXProto.h
@@ -0,0 +1,125 @@
+/*
+Copyright (C) 2009 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 __IAXPROTO_H__
+#define __IAXPROTO_H__
+
+
+class IAXProto;
+typedef INT_PTR (__cdecl IAXProto::*IAXServiceFunc)(WPARAM, LPARAM);
+typedef INT_PTR (__cdecl IAXProto::*IAXServiceFuncParam)(WPARAM, LPARAM, LPARAM);
+
+
+class IAXProto : public PROTO_INTERFACE
+{
+private:
+ HANDLE hNetlibUser;
+ int reg_id;
+
+ struct {
+ TCHAR host[256];
+ int port;
+ TCHAR username[16];
+ char password[16];
+ BYTE savePassword;
+ } opts;
+
+public:
+ CRITICAL_SECTION cs;
+ std::vector<iaxc_event> events;
+ OptPageControl accountManagerCtrls[5];
+
+ IAXProto(const char *aProtoName, const TCHAR *aUserName);
+ virtual ~IAXProto();
+
+ virtual HANDLE __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr ) { return 0; }
+ virtual HANDLE __cdecl AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; }
+
+ virtual int __cdecl Authorize( HANDLE hDbEvent ) { return 1; }
+ virtual int __cdecl AuthDeny( HANDLE hDbEvent, const char* szReason ) { return 1; }
+ virtual int __cdecl AuthRecv( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl AuthRequest( HANDLE hContact, const char* szMessage ) { return 1; }
+
+ virtual HANDLE __cdecl ChangeInfo( int iInfoType, void* pInfoData ) { return 0; }
+
+ virtual HANDLE __cdecl FileAllow( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath ) { return 0; }
+ virtual int __cdecl FileCancel( HANDLE hContact, HANDLE hTransfer ) { return 1; }
+ virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason ) { return 1; }
+ virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename ) { return 1; }
+
+ virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL );
+
+ virtual HICON __cdecl GetIcon( int iconIndex ) { return 0; }
+ virtual int __cdecl GetInfo( HANDLE hContact, int infoType ) { return 1; }
+
+ virtual HANDLE __cdecl SearchBasic( const char* id ) { return 0; }
+ virtual HANDLE __cdecl SearchByEmail( const char* email ) { return 0; }
+ virtual HANDLE __cdecl SearchByName( const char* nick, const char* firstName, const char* lastName ) { return 0; }
+ virtual HWND __cdecl SearchAdvanced( HWND owner ) { return 0; }
+ virtual HWND __cdecl CreateExtendedSearchUI( HWND owner ) { return 0; }
+
+ virtual int __cdecl RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl RecvFile( HANDLE hContact, PROTOFILEEVENT* ) { return 1; }
+ virtual int __cdecl RecvMsg( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
+ virtual int __cdecl RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
+
+ virtual int __cdecl SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 1; }
+ virtual HANDLE __cdecl SendFile( HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles ) { return 0; }
+ virtual int __cdecl SendMsg( HANDLE hContact, int flags, const char* msg ) { return 1; }
+ virtual int __cdecl SendUrl( HANDLE hContact, int flags, const char* url ) { return 1; }
+
+ virtual int __cdecl SetApparentMode( HANDLE hContact, int mode ) { return 1; }
+
+ virtual int __cdecl SetStatus( int iNewStatus );
+
+ virtual HANDLE __cdecl GetAwayMsg( HANDLE hContact ) { return 0; }
+ virtual int __cdecl RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt ) { return 1; }
+ virtual int __cdecl SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 1; }
+ virtual int __cdecl SetAwayMsg( int iStatus, const char* msg ) { return 1; }
+
+ virtual int __cdecl UserIsTyping( HANDLE hContact, int type ) { return 0; }
+
+ virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam ) { return 1; }
+
+ int iaxc_callback(iaxc_event &e);
+
+private:
+ void BroadcastStatus(int newStatus);
+ void CreateProtoService(const char* szService, IAXServiceFunc serviceProc);
+ void CreateProtoService(const char* szService, IAXServiceFuncParam serviceProc, LPARAM lParam);
+ HANDLE CreateProtoEvent(const char* szService);
+ int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+
+ void ShowMessage(bool error, TCHAR *fmt, ...);
+ void Disconnect();
+ INT_PTR __cdecl CreateAccMgrUI(WPARAM wParam, LPARAM lParam);
+
+ int levels_callback(iaxc_ev_levels &levels);
+ int text_callback(iaxc_ev_text &text);
+ int state_callback(iaxc_ev_call_state &call);
+ int netstats_callback(iaxc_ev_netstats &netstats);
+ int url_callback(iaxc_ev_url &url);
+ int registration_callback(iaxc_ev_registration &reg);
+
+};
+
+
+
+
+#endif // __IAXPROTO_H__
diff --git a/Protocols/IAX/commons.h b/Protocols/IAX/commons.h
index 2825e39..b501be1 100644
--- a/Protocols/IAX/commons.h
+++ b/Protocols/IAX/commons.h
@@ -31,6 +31,7 @@ Boston, MA 02111-1307, USA.
#include <time.h>
#include <vector>
+#include <list>
// Miranda headers
#define MIRANDA_VER 0x0900
@@ -62,12 +63,14 @@ Boston, MA 02111-1307, USA.
#include "../../plugins/utils/mir_options.h"
#include "../../plugins/utils/mir_icons.h"
#include "../../plugins/utils/mir_log.h"
+#include "../../plugins/utils/utf8_helpers.h"
#include <iaxclient.h>
#include "resource.h"
#include "m_iax.h"
#include "options.h"
+#include "IAXProto.h"
#define MODULE_NAME "IAX"
@@ -76,6 +79,7 @@ Boston, MA 02111-1307, USA.
// Global Variables
extern HINSTANCE hInst;
extern PLUGINLINK *pluginLink;
+extern OBJLIST<IAXProto> instances;
#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
#define MIR_FREE(_X_) if (_X_ != NULL) { mir_free(_X_); _X_ = NULL; }
diff --git a/Protocols/IAX/iax.cpp b/Protocols/IAX/iax.cpp
index 4b99e0a..9376ac3 100644
--- a/Protocols/IAX/iax.cpp
+++ b/Protocols/IAX/iax.cpp
@@ -54,195 +54,11 @@ LIST_INTERFACE li;
std::vector<HANDLE> hHooks;
std::vector<HANDLE> hServices;
+OBJLIST<IAXProto> instances(1);
int ModulesLoaded(WPARAM wParam, LPARAM lParam);
int PreShutdown(WPARAM wParam, LPARAM lParam);
-// IAXProto /////////////////////////////////////////////////////////////////////////////
-
-class IAXProto;
-typedef INT_PTR (IAXProto::*IAXServiceFunc)(WPARAM, LPARAM);
-typedef INT_PTR (IAXProto::*IAXServiceFuncParam)(WPARAM, LPARAM, LPARAM);
-
-class IAXProto : public PROTO_INTERFACE
-{
-private:
- HANDLE hNetlibUser;
-
-public:
- IAXProto(const char *aProtoName, const TCHAR *aUserName)
- {
- m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
-
- m_tszUserName = mir_tstrdup(aUserName);
- m_szProtoName = mir_strdup(aProtoName);
- m_szModuleName = mir_strdup(aProtoName);
-
- TCHAR buffer[MAX_PATH];
- mir_sntprintf(buffer, MAX_REGS(buffer), TranslateT("%s plugin connections"), m_tszUserName);
-
- NETLIBUSER nl_user = {0};
- nl_user.cbSize = sizeof(nl_user);
- nl_user.flags = NUF_OUTGOING | NUF_TCHAR;
- nl_user.szSettingsModule = m_szModuleName;
- nl_user.ptszDescriptiveName = buffer;
- hNetlibUser = (HANDLE) CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user);
- }
-
- ~IAXProto()
- {
- Netlib_CloseHandle(hNetlibUser);
-
- mir_free(m_tszUserName);
- mir_free(m_szProtoName);
- mir_free(m_szModuleName);
- }
-
- virtual HANDLE __cdecl AddToList( int flags, PROTOSEARCHRESULT* psr ) { return 0; }
- virtual HANDLE __cdecl AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; }
-
- virtual int __cdecl Authorize( HANDLE hDbEvent ) { return 1; }
- virtual int __cdecl AuthDeny( HANDLE hDbEvent, const char* szReason ) { return 1; }
- virtual int __cdecl AuthRecv( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl AuthRequest( HANDLE hContact, const char* szMessage ) { return 1; }
-
- virtual HANDLE __cdecl ChangeInfo( int iInfoType, void* pInfoData ) { return 0; }
-
- virtual HANDLE __cdecl FileAllow( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath ) { return 0; }
- virtual int __cdecl FileCancel( HANDLE hContact, HANDLE hTransfer ) { return 1; }
- virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason ) { return 1; }
- virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename ) { return 1; }
-
- virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL )
- {
- switch(type)
- {
- case PFLAGNUM_1:
- return 0;
-
- case PFLAGNUM_2:
- return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND
- | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE | PF2_INVISIBLE | PF2_IDLE;
-
- case PFLAGNUM_3:
- return 0;
-
- case PFLAGNUM_4:
- return PF4_NOCUSTOMAUTH;
-
- case PFLAG_UNIQUEIDTEXT:
- return NULL;
-
- case PFLAG_UNIQUEIDSETTING:
- return NULL;
-
- case PFLAG_MAXLENOFMESSAGE:
- return 100;
- }
-
- return 0;
- }
-
- virtual HICON __cdecl GetIcon( int iconIndex ) { return 0; }
- virtual int __cdecl GetInfo( HANDLE hContact, int infoType ) { return 1; }
-
- virtual HANDLE __cdecl SearchBasic( const char* id ) { return 0; }
- virtual HANDLE __cdecl SearchByEmail( const char* email ) { return 0; }
- virtual HANDLE __cdecl SearchByName( const char* nick, const char* firstName, const char* lastName ) { return 0; }
- virtual HWND __cdecl SearchAdvanced( HWND owner ) { return 0; }
- virtual HWND __cdecl CreateExtendedSearchUI( HWND owner ) { return 0; }
-
- virtual int __cdecl RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl RecvFile( HANDLE hContact, PROTOFILEEVENT* ) { return 1; }
- virtual int __cdecl RecvMsg( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
- virtual int __cdecl RecvUrl( HANDLE hContact, PROTORECVEVENT* ) { return 1; }
-
- virtual int __cdecl SendContacts( HANDLE hContact, int flags, int nContacts, HANDLE* hContactsList ) { return 1; }
- virtual HANDLE __cdecl SendFile( HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles ) { return 0; }
- virtual int __cdecl SendMsg( HANDLE hContact, int flags, const char* msg ) { return 1; }
- virtual int __cdecl SendUrl( HANDLE hContact, int flags, const char* url ) { return 1; }
-
- virtual int __cdecl SetApparentMode( HANDLE hContact, int mode ) { return 1; }
- virtual int __cdecl SetStatus( int iNewStatus )
- {
- if (m_iDesiredStatus == iNewStatus)
- return 0;
- m_iDesiredStatus = iNewStatus;
-
- if (m_iDesiredStatus == ID_STATUS_OFFLINE)
- {
- BroadcastStatus(ID_STATUS_OFFLINE);
- }
- else if (m_iStatus == ID_STATUS_OFFLINE)
- {
- BroadcastStatus(ID_STATUS_CONNECTING);
- }
- else if (m_iStatus > ID_STATUS_OFFLINE)
- {
- BroadcastStatus(m_iDesiredStatus);
- }
-
- return 0;
- }
-
- virtual HANDLE __cdecl GetAwayMsg( HANDLE hContact ) { return 0; }
- virtual int __cdecl RecvAwayMsg( HANDLE hContact, int mode, PROTORECVEVENT* evt ) { return 1; }
- virtual int __cdecl SendAwayMsg( HANDLE hContact, HANDLE hProcess, const char* msg ) { return 1; }
- virtual int __cdecl SetAwayMsg( int iStatus, const char* msg ) { return 1; }
-
- virtual int __cdecl UserIsTyping( HANDLE hContact, int type ) { return 0; }
-
- virtual int __cdecl OnEvent( PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam ) { return 1; }
-
-
-
-private:
- void BroadcastStatus(int newStatus)
- {
- int oldStatus = m_iStatus;
- m_iStatus = newStatus;
- SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
- }
-
- void CreateProtoService(const char* szService, IAXServiceFunc serviceProc)
- {
- char str[MAXMODULELABELLENGTH];
-
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- ::CreateServiceFunctionObj(str, (MIRANDASERVICEOBJ)*(void**)&serviceProc, this);
- }
-
- void CreateProtoService(const char* szService, IAXServiceFuncParam serviceProc, LPARAM lParam)
- {
- char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam);
- }
-
- HANDLE CreateProtoEvent(const char* szService)
- {
- char str[MAXMODULELABELLENGTH];
- mir_snprintf(str, sizeof(str), "%s%s", m_szModuleName, szService);
- return ::CreateHookableEvent(str);
- }
-
- int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
- {
- ACKDATA ack = {0};
- ack.cbSize = sizeof(ACKDATA);
- ack.szModule = m_szModuleName;
- ack.hContact = hContact;
- ack.type = type;
- ack.result = result;
- ack.hProcess = hProcess;
- ack.lParam = lParam;
- return CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);
- }
-
-
-};
-
-OBJLIST<IAXProto> instances(1);
// Functions ////////////////////////////////////////////////////////////////////////////
@@ -367,4 +183,3 @@ int PreShutdown(WPARAM wParam, LPARAM lParam)
return 0;
}
-
diff --git a/Protocols/IAX/iax.dsp b/Protocols/IAX/iax.dsp
index 64d1d3f..abcbf24 100644
--- a/Protocols/IAX/iax.dsp
+++ b/Protocols/IAX/iax.dsp
@@ -164,6 +164,10 @@ SOURCE=.\commons.h
# End Source File
# Begin Source File
+SOURCE=.\IAXProto.h
+# End Source File
+# Begin Source File
+
SOURCE=.\m_iax.h
# End Source File
# Begin Source File
@@ -208,6 +212,10 @@ SOURCE=.\iax.cpp
# End Source File
# Begin Source File
+SOURCE=.\IAXProto.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\plugins\utils\mir_icons.cpp
# End Source File
# Begin Source File
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libgsm.lib b/Protocols/IAX/lib/iaxclient/Debug/libgsm.lib
index 3f5b976..79957a8 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libgsm.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libgsm.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libiax2.lib b/Protocols/IAX/lib/iaxclient/Debug/libiax2.lib
index 60acf2b..485afa4 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libiax2.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libiax2.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libiaxclient.lib b/Protocols/IAX/lib/iaxclient/Debug/libiaxclient.lib
index fa48ed8..4bf8d9d 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libiaxclient.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libiaxclient.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libogg.lib b/Protocols/IAX/lib/iaxclient/Debug/libogg.lib
index 2f74751..0096216 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libogg.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libogg.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libportaudio.lib b/Protocols/IAX/lib/iaxclient/Debug/libportaudio.lib
index 0bbbf1b..46010cc 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libportaudio.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libportaudio.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libportmixer.lib b/Protocols/IAX/lib/iaxclient/Debug/libportmixer.lib
index dd10033..02dbc95 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libportmixer.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libportmixer.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Debug/libspeex.lib b/Protocols/IAX/lib/iaxclient/Debug/libspeex.lib
index f571d31..222145d 100644
--- a/Protocols/IAX/lib/iaxclient/Debug/libspeex.lib
+++ b/Protocols/IAX/lib/iaxclient/Debug/libspeex.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libgsm.lib b/Protocols/IAX/lib/iaxclient/Release/libgsm.lib
index b410d9d..e802484 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libgsm.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libgsm.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libiax2.lib b/Protocols/IAX/lib/iaxclient/Release/libiax2.lib
index 3af1037..623d0c8 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libiax2.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libiax2.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libiaxclient.lib b/Protocols/IAX/lib/iaxclient/Release/libiaxclient.lib
index 72a00ec..f6c2ca2 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libiaxclient.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libiaxclient.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libogg.lib b/Protocols/IAX/lib/iaxclient/Release/libogg.lib
index 5d508ea..5fa9864 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libogg.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libogg.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libportaudio.lib b/Protocols/IAX/lib/iaxclient/Release/libportaudio.lib
index 2b6b0d4..aa4ff2c 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libportaudio.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libportaudio.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libportmixer.lib b/Protocols/IAX/lib/iaxclient/Release/libportmixer.lib
index 1ee38c1..7bd59ab 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libportmixer.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libportmixer.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/Release/libspeex.lib b/Protocols/IAX/lib/iaxclient/Release/libspeex.lib
index da7d543..ebd892a 100644
--- a/Protocols/IAX/lib/iaxclient/Release/libspeex.lib
+++ b/Protocols/IAX/lib/iaxclient/Release/libspeex.lib
Binary files differ
diff --git a/Protocols/IAX/lib/iaxclient/iaxclient.h b/Protocols/IAX/lib/iaxclient/iaxclient.h
index 9d602e2..92e8f72 100644
--- a/Protocols/IAX/lib/iaxclient/iaxclient.h
+++ b/Protocols/IAX/lib/iaxclient/iaxclient.h
@@ -599,13 +599,14 @@ typedef struct iaxc_event_struct {
\return The result of processing the event; > 0 if successfully handled the event, 0 if not handled, < 0 to indicate an error occurred processing the event.
*/
-typedef int (*iaxc_event_callback_t)(iaxc_event e);
+typedef int (*iaxc_event_callback_t)(iaxc_event e, void *param);
/*!
Sets the callback to call with IAXClient events
\param func The callback function to call with events
+ \param param User data to pass to the callback function
*/
-EXPORT void iaxc_set_event_callback(iaxc_event_callback_t func);
+EXPORT void iaxc_set_event_callback(iaxc_event_callback_t func, void *param);
/*!
Sets iaxclient to post a pointer to a copy of event using o/s specific Post method
diff --git a/Protocols/IAX/resource.h b/Protocols/IAX/resource.h
index 5e72d46..8df85fd 100644
--- a/Protocols/IAX/resource.h
+++ b/Protocols/IAX/resource.h
@@ -5,6 +5,12 @@
#define IDD_OPTIONS 119
#define IDD_OPTIONS_OLD 120
#define IDD_EMOTICON_SELECTION 126
+#define IDD_ACCMGRUI 227
+#define IDC_USERNAME 1000
+#define IDC_PASSWORD 1001
+#define IDC_PORT 1004
+#define IDC_HOST 1043
+#define IDC_SAVEPASSWORD 1048
#define IDC_INPUT_TOO 1060
#define IDC_IGNORE_UPPERCASE 1065
#define IDC_AUTO_USER 1066
diff --git a/Protocols/IAX/resource.rc b/Protocols/IAX/resource.rc
index 1ec4ab6..b51a5bb 100644
--- a/Protocols/IAX/resource.rc
+++ b/Protocols/IAX/resource.rc
@@ -14,11 +14,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// Neutral resources
+// English (U.S.) resources
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
@@ -27,54 +27,24 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// Dialog
//
-IDD_EMOTICON_SELECTION DIALOGEX 0, 0, 188, 90
-STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_BORDER
-EXSTYLE WS_EX_NOPARENTNOTIFY
-FONT 8, "MS Sans Serif", 0, 0, 0x1
-BEGIN
-END
-
-IDD_OPTIONS DIALOGEX 0, 0, 293, 247
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
+IDD_ACCMGRUI DIALOGEX 0, 0, 186, 134
+STYLE DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg"
BEGIN
- LISTBOX IDC_PACK,7,2,277,148,LBS_OWNERDRAWVARIABLE |
- LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
- CONTROL "Embed videos",IDC_VIDEO,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,7,159,277,10
- CONTROL "Enable custom smileys",IDC_CUSTOM_SMILEYS,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,7,171,277,10
- CONTROL "Replace emoticons in text input area too",IDC_INPUT_TOO,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,183,277,10
- CONTROL "Use default emoticon pack for unknown protocols",
- IDC_USE_DEFAULT_PACK,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,7,195,277,10
- CONTROL "Only replace emoticons surrounded by spaces",
- IDC_ONLY_ISOLATED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 7,207,277,10
- CONTROL "Download more emoticon packs",IDC_GETMORE,"Hyperlink",
- WS_TABSTOP | 0x1,7,231,277,12
+ LTEXT "Server:",IDC_STATIC,0,0,53,12,SS_CENTERIMAGE
+ EDITTEXT IDC_HOST,54,0,92,12,ES_AUTOHSCROLL
+ CTEXT ":",IDC_STATIC,147,0,8,12,SS_CENTERIMAGE
+ EDITTEXT IDC_PORT,155,0,30,12,ES_AUTOHSCROLL | ES_NUMBER
+ LTEXT "User:",IDC_STATIC,0,16,53,12,SS_CENTERIMAGE
+ EDITTEXT IDC_USERNAME,54,16,131,12,ES_AUTOHSCROLL
+ LTEXT "Password:",IDC_STATIC,0,31,53,12,SS_CENTERIMAGE
+ EDITTEXT IDC_PASSWORD,54,32,131,12,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Save password",IDC_SAVEPASSWORD,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,54,48,131,10
END
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO MOVEABLE PURE
-BEGIN
- IDD_OPTIONS, DIALOG
- BEGIN
- LEFTMARGIN, 1
- TOPMARGIN, 1
- END
-END
-#endif // APSTUDIO_INVOKED
-
-#endif // Neutral resources
+#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////