From 21f8ca06b26fe42f8bbf8ca477a2824989ff13c7 Mon Sep 17 00:00:00 2001 From: pescuma Date: Sat, 26 Dec 2009 01:17:57 +0000 Subject: iax: fixes and update to new structs of voice service git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@193 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Protocols/IAX/IAXProto.cpp | 75 +++++++++++++++--------------------- Protocols/IAX/IAXProto.h | 3 +- Protocols/IAX/commons.h | 3 -- Protocols/IAX/iax.cpp | 10 ++++- Protocols/IAX/iax.dsp | 12 ------ Protocols/IAX/m_iax.h | 27 ------------- Protocols/IAX/options.cpp | 96 ---------------------------------------------- Protocols/IAX/options.h | 47 ----------------------- 8 files changed, 41 insertions(+), 232 deletions(-) delete mode 100644 Protocols/IAX/m_iax.h delete mode 100644 Protocols/IAX/options.cpp delete mode 100644 Protocols/IAX/options.h (limited to 'Protocols/IAX') diff --git a/Protocols/IAX/IAXProto.cpp b/Protocols/IAX/IAXProto.cpp index fe53fb5..73b0aef 100644 --- a/Protocols/IAX/IAXProto.cpp +++ b/Protocols/IAX/IAXProto.cpp @@ -78,13 +78,16 @@ IAXProto::IAXProto(const char *aProtoName, const TCHAR *aUserName) CreateProtoService(PS_CREATEACCMGRUI, &IAXProto::CreateAccMgrUI); + CreateProtoService(PS_VOICE_CAPS, &IAXProto::VoiceCaps); CreateProtoService(PS_VOICE_CALL, &IAXProto::VoiceCall); CreateProtoService(PS_VOICE_ANSWERCALL, &IAXProto::VoiceAnswerCall); CreateProtoService(PS_VOICE_DROPCALL, &IAXProto::VoiceDropCall); CreateProtoService(PS_VOICE_HOLDCALL, &IAXProto::VoiceHoldCall); - //CreateProtoService(PS_VOICE_SEND_DTMF, &IAXProto::VoiceSendDTMF); + CreateProtoService(PS_VOICE_SEND_DTMF, &IAXProto::VoiceSendDTMF); CreateProtoService(PS_VOICE_CALL_STRING_VALID, &IAXProto::VoiceCallStringValid); + hCallStateEvent = CreateProtoEvent(PE_VOICE_CALL_STATE); + HookProtoEvent(ME_OPT_INITIALISE, &IAXProto::OnOptionsInit); } @@ -119,10 +122,10 @@ DWORD_PTR __cdecl IAXProto::GetCaps( int type, HANDLE hContact ) return PF4_NOCUSTOMAUTH; case PFLAG_UNIQUEIDTEXT: - return NULL; + return (UINT_PTR) Translate("User"); case PFLAG_UNIQUEIDSETTING: - return NULL; + return (UINT_PTR) "Username"; case PFLAG_MAXLENOFMESSAGE: return 100; @@ -357,12 +360,12 @@ int IAXProto::state_callback(iaxc_ev_call_state &call) return 0; } - bool outgoing = ((call.state & IAXC_CALL_STATE_OUTGOING) != 0); - - TCHAR buffer[256] = {0}; - TCHAR *number = NULL; + TCHAR name[256]; + TCHAR number[256]; + name[0] = 0; + number[0] = 0; - if (!outgoing) + if ((call.state & IAXC_CALL_STATE_OUTGOING) == 0) { const char *otherName = call.remote_name; const char *otherNumber = call.remote; @@ -372,47 +375,36 @@ int IAXProto::state_callback(iaxc_ev_call_state &call) if (strcmp(otherNumber, "unknown") == 0) otherNumber = NULL; - if (otherName == NULL && otherNumber == NULL) - { - lstrcpyn(buffer, TranslateT(""), MAX_REGS(buffer)); - } - else if (otherName == NULL) + if (otherName != NULL) { - lstrcpyn(buffer, Utf8ToTchar(otherNumber), MAX_REGS(buffer)); + lstrcpyn(name, Utf8ToTchar(otherName), MAX_REGS(name)); + lstrtrim(name); } - else if (otherNumber == NULL) + if (otherNumber != NULL) { - lstrcpyn(buffer, Utf8ToTchar(otherName), MAX_REGS(buffer)); + lstrcpyn(number, Utf8ToTchar(otherNumber), MAX_REGS(number)); + lstrtrim(number); } - else - { - mir_sntprintf(buffer, MAX_REGS(buffer), TranslateT("%s <%s>"), - Utf8ToTchar(otherName).get(), - Utf8ToTchar(otherNumber).get()); - } - - lstrtrim(buffer); - number = buffer; } if (call.state & IAXC_CALL_STATE_BUSY) { - NotifyCall(call.callNo, VOICE_STATE_BUSY, NULL, number); + NotifyCall(call.callNo, VOICE_STATE_BUSY, NULL, name, number); } else if (call.state & IAXC_CALL_STATE_RINGING) { - NotifyCall(call.callNo, VOICE_STATE_RINGING, NULL, number); + NotifyCall(call.callNo, VOICE_STATE_RINGING, NULL, name, number); } else if (!(call.state & IAXC_CALL_STATE_COMPLETE)) { - NotifyCall(call.callNo, VOICE_STATE_CALLING, NULL, number); + NotifyCall(call.callNo, VOICE_STATE_CALLING, NULL, name, number); } else { if (call.callNo == iaxc_selected_call()) - NotifyCall(call.callNo, VOICE_STATE_TALKING, NULL, number); + NotifyCall(call.callNo, VOICE_STATE_TALKING, NULL, name, number); else - NotifyCall(call.callNo, VOICE_STATE_ON_HOLD, NULL, number); + NotifyCall(call.callNo, VOICE_STATE_ON_HOLD, NULL, name, number); } return 0; @@ -579,16 +571,6 @@ int __cdecl IAXProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) return 1; } - - hCallStateEvent = CreateProtoEvent(PE_VOICE_CALL_STATE); - - VOICE_MODULE vm = {0}; - vm.cbSize = sizeof(vm); - vm.name = m_szModuleName; - vm.description = m_tszUserName; - vm.flags = VOICE_CAPS_CALL_STRING; - CallService(MS_VOICESERVICE_REGISTER, (WPARAM) &vm, 0); - return 0; } @@ -612,8 +594,6 @@ int __cdecl IAXProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) int __cdecl IAXProto::OnPreShutdown(WPARAM wParam, LPARAM lParam) { - CallService(MS_VOICESERVICE_UNREGISTER, (WPARAM) m_szModuleName, 0); - iaxc_stop_processing_thread(); iaxc_shutdown(); @@ -622,7 +602,7 @@ int __cdecl IAXProto::OnPreShutdown(WPARAM wParam, LPARAM lParam) } -void IAXProto::NotifyCall(int callNo, int state, HANDLE hContact, TCHAR *number) +void IAXProto::NotifyCall(int callNo, int state, HANDLE hContact, TCHAR *name, TCHAR *number) { Trace(_T("NotifyCall %d -> %d"), callNo, state); @@ -634,6 +614,7 @@ void IAXProto::NotifyCall(int callNo, int state, HANDLE hContact, TCHAR *number) vc.id = itoa(callNo, tmp, 10); vc.flags = VOICE_TCHAR; vc.hContact = hContact; + vc.ptszName = name; vc.ptszNumber = number; vc.state = state; @@ -702,6 +683,12 @@ void IAXProto::ConfigureDevices() } +int __cdecl IAXProto::VoiceCaps(WPARAM wParam,LPARAM lParam) +{ + return VOICE_CAPS_VOICE | VOICE_CAPS_CALL_STRING; +} + + int __cdecl IAXProto::VoiceCall(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE) wParam; @@ -739,7 +726,7 @@ int __cdecl IAXProto::VoiceCall(WPARAM wParam, LPARAM lParam) return 3; } - NotifyCall(callNo, VOICE_STATE_CALLING, hContact, number); + NotifyCall(callNo, VOICE_STATE_CALLING, hContact, NULL, number); return 0; } diff --git a/Protocols/IAX/IAXProto.h b/Protocols/IAX/IAXProto.h index fc21714..db0549b 100644 --- a/Protocols/IAX/IAXProto.h +++ b/Protocols/IAX/IAXProto.h @@ -136,7 +136,8 @@ private: void ConfigureDevices(); // Voice services - void NotifyCall(int callNo, int state, HANDLE hContact = NULL, TCHAR *number = NULL); + void NotifyCall(int callNo, int state, HANDLE hContact = NULL, TCHAR *name = NULL, TCHAR *number = NULL); + int __cdecl VoiceCaps(WPARAM wParam,LPARAM lParam); int __cdecl VoiceCall(WPARAM wParam,LPARAM lParam); int __cdecl VoiceAnswerCall(WPARAM wParam,LPARAM lParam); int __cdecl VoiceDropCall(WPARAM wParam,LPARAM lParam); diff --git a/Protocols/IAX/commons.h b/Protocols/IAX/commons.h index 3f5e762..2203660 100644 --- a/Protocols/IAX/commons.h +++ b/Protocols/IAX/commons.h @@ -70,8 +70,6 @@ Boston, MA 02111-1307, USA. #include #include "resource.h" -#include "m_iax.h" -#include "options.h" #include "IAXProto.h" @@ -85,7 +83,6 @@ extern OBJLIST instances; #define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) ) #define MIR_FREE(_X_) if (_X_ != NULL) { mir_free(_X_); _X_ = NULL; } -#define RELEASE(_X_) if (_X_ != NULL) { _X_->Release(); _X_ = NULL; } diff --git a/Protocols/IAX/iax.cpp b/Protocols/IAX/iax.cpp index 54f089a..4fbf873 100644 --- a/Protocols/IAX/iax.cpp +++ b/Protocols/IAX/iax.cpp @@ -53,13 +53,19 @@ UTF8_INTERFACE utfi; LIST_INTERFACE li; std::vector hHooks; -std::vector hServices; -OBJLIST instances(1); int ModulesLoaded(WPARAM wParam, LPARAM lParam); int PreShutdown(WPARAM wParam, LPARAM lParam); +static int sttCompareProtocols(const IAXProto *p1, const IAXProto *p2) +{ + return strcmp(p1->m_szModuleName, p2->m_szModuleName); +} +OBJLIST instances(1, &sttCompareProtocols); + + + // Functions //////////////////////////////////////////////////////////////////////////// diff --git a/Protocols/IAX/iax.dsp b/Protocols/IAX/iax.dsp index abcbf24..f257ed9 100644 --- a/Protocols/IAX/iax.dsp +++ b/Protocols/IAX/iax.dsp @@ -168,10 +168,6 @@ SOURCE=.\IAXProto.h # End Source File # Begin Source File -SOURCE=.\m_iax.h -# End Source File -# Begin Source File - SOURCE=..\..\plugins\utils\mir_icons.h # End Source File # Begin Source File @@ -188,10 +184,6 @@ SOURCE=..\..\plugins\utils\mir_options.h # End Source File # Begin Source File -SOURCE=.\options.h -# End Source File -# Begin Source File - SOURCE=.\resource.h # End Source File # End Group @@ -226,10 +218,6 @@ SOURCE=..\..\plugins\utils\mir_log.cpp SOURCE=..\..\plugins\utils\mir_options.cpp # End Source File -# Begin Source File - -SOURCE=.\options.cpp -# End Source File # End Group # Begin Group "Docs" diff --git a/Protocols/IAX/m_iax.h b/Protocols/IAX/m_iax.h deleted file mode 100644 index 37c46ea..0000000 --- a/Protocols/IAX/m_iax.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -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 __M_IAX_H__ -# define __M_IAX_H__ - - - - -#endif // __M_IAX_H__ diff --git a/Protocols/IAX/options.cpp b/Protocols/IAX/options.cpp deleted file mode 100644 index 6fe3edd..0000000 --- a/Protocols/IAX/options.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright (C) 2008 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" - -#include "options.h" - - - -// Prototypes ///////////////////////////////////////////////////////////////////////////////////// - -HANDLE hOptHook = NULL; - -Options opts; - - -static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); - - -static OptPageControl optionsControls[] = { - {0} -}; - -static UINT optionsExpertControls[] = { - {0} -}; - - -// Functions ////////////////////////////////////////////////////////////////////////////////////// - - -int InitOptionsCallback(WPARAM wParam,LPARAM lParam) -{ -/* - OPTIONSDIALOGPAGE odp; - - ZeroMemory(&odp,sizeof(odp)); - odp.cbSize=sizeof(odp); - odp.position=0; - odp.hInstance=hInst; - odp.ptszGroup = TranslateT("Message Sessions"); - odp.ptszTitle = TranslateT("Emoticons"); - odp.pfnDlgProc = OptionsDlgProc; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR; - odp.expertOnlyControls = optionsExpertControls; - odp.nExpertOnlyControls = MAX_REGS(optionsExpertControls); - CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); -*/ - return 0; -} - - -void InitOptions() -{ - LoadOptions(); - - hOptHook = HookEvent(ME_OPT_INITIALISE, InitOptionsCallback); -} - - -void DeInitOptions() -{ - UnhookEvent(hOptHook); -} - - -void LoadOptions() -{ - LoadOpts(optionsControls, MAX_REGS(optionsControls), MODULE_NAME); - -} - -static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - return SaveOptsDlgProc(optionsControls, MAX_REGS(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam); -} - - diff --git a/Protocols/IAX/options.h b/Protocols/IAX/options.h deleted file mode 100644 index 7b2616c..0000000 --- a/Protocols/IAX/options.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright (C) 2008 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 __OPTIONS_H__ -# define __OPTIONS_H__ - - -#include - - -struct Options { -}; - -extern Options opts; - - -// Initializations needed by options -void InitOptions(); - -// Deinitializations needed by options -void DeInitOptions(); - - -// Loads the options from DB -// It don't need to be called, except in some rare cases -void LoadOptions(); - - - -#endif // __OPTIONS_H__ -- cgit v1.2.3