diff options
author | George Hazan <ghazan@miranda.im> | 2020-03-11 19:50:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-03-11 19:50:57 +0300 |
commit | e8fb7de563970da12871b83c0c5e84775fe71d2d (patch) | |
tree | 6ff2dadfba3045ca646fa903d2fe16ec0bfe32f2 | |
parent | 647b4697b51d8a3cf52b7c0312b6adc89e4cf395 (diff) |
Voice API: code cleaning
-rw-r--r-- | plugins/ExternalAPI/m_voice.h | 75 | ||||
-rw-r--r-- | plugins/ExternalAPI/m_voiceservice.h | 15 | ||||
-rw-r--r-- | plugins/VoiceService/src/VoiceProvider.cpp | 21 | ||||
-rw-r--r-- | plugins/VoiceService/src/main.cpp | 2 | ||||
-rw-r--r-- | plugins/VoiceService/src/stdafx.h | 22 |
5 files changed, 52 insertions, 83 deletions
diff --git a/plugins/ExternalAPI/m_voice.h b/plugins/ExternalAPI/m_voice.h index e88eaeb842..046eae5383 100644 --- a/plugins/ExternalAPI/m_voice.h +++ b/plugins/ExternalAPI/m_voice.h @@ -35,18 +35,10 @@ wParam: 0 lParam: 0 return: VOICE_CAPS_* */ -#define PS_VOICE_CAPS "/Voice/Caps" +#define PS_VOICE_CAPS "/Voice/Caps" - - -#define VOICE_SECURE 0x00000001 -#define VOICE_UNICODE 0x80000000 - -#ifdef UNICODE -# define VOICE_TCHAR VOICE_UNICODE -#else -# define VOICE_TCHAR 0 -#endif +#define VOICE_SECURE 0x00000001 +#define VOICE_UNICODE 0x80000000 #define VOICE_STATE_TALKING 0 #define VOICE_STATE_RINGING 1 @@ -55,32 +47,23 @@ return: VOICE_CAPS_* #define VOICE_STATE_ENDED 4 #define VOICE_STATE_BUSY 5 -typedef struct { - int cbSize; // Struct size - const char *moduleName; // The name of the module (the same as VOICE_MODULE.name or the protocol szModule) - char *id; // Protocol especific ID for this call - int flags; // VOICE_UNICODE to say the string is unicode or 0. VOICE_SECURE to say this is a - // encrypted call - - MCONTACT hContact; // Contact associated with the call (can be NULL) - - union { // Number to call (can be NULL) - const TCHAR *ptszNumber;// Or the contact or the number must be != NULL - const char *pszNumber; // If both are != NULL the call will be made to the number - const WCHAR *pwszNumber;// and will be associated with the contact - }; // This fields are only needed in first notification for a call id - - union { // Name of the caller. This makes sense only on incoming calls, - const TCHAR *ptszName; // where no contact is associated and the caller has a name and a number. - const char *pszName; - const WCHAR *pwszName; - }; - +struct VOICE_CALL +{ + int cbSize; // Struct size + const char *moduleName; // The name of the module (the same as VOICE_MODULE.name or the protocol szModule) + char *id; // Protocol especific ID for this call + int flags; // VOICE_UNICODE to say the string is unicode or 0. VOICE_SECURE to say this is an encrypted call - int state; // VOICE_STATE_* - -} VOICE_CALL; + // Either contact or number must be != NULL + // If both are != NULL the call will be made to the number and will be associated with the contact + // This fields are only needed in first notification for a call id + MCONTACT hContact; // Contact associated with the call (can be NULL) + MAllCStrings szNumber; // Number to call (can be NULL) + MAllCStrings szName; // Name of the caller. This makes sense only on incoming calls, + // where no contact is associated and the caller has a name and a number. + int state; // VOICE_STATE_* +}; /* Notifies that a voice call changed state @@ -89,9 +72,7 @@ wParam: const VOICE_CALL * lParam: ignored return: 0 on success */ -#define PE_VOICE_CALL_STATE "/Voice/State" - - +#define PE_VOICE_CALL_STATE "/Voice/State" /* Request the protocol to make a voice call @@ -102,7 +83,7 @@ return: 0 on success Or the contact or the number must be != NULL. If both are != NULL the call will be made to the number and will be associated with the contact. */ -#define PS_VOICE_CALL "/Voice/Call" +#define PS_VOICE_CALL "/Voice/Call" /* Service called to make the protocol answer a call or restore a hold call. @@ -113,7 +94,7 @@ wParam: (const char *) id lParam: ignored return: 0 on success */ -#define PS_VOICE_ANSWERCALL "/Voice/AnswerCall" +#define PS_VOICE_ANSWERCALL "/Voice/AnswerCall" /* Service called to make the protocol answer a call. This can be called if the @@ -125,7 +106,7 @@ wParam: (const char *) id lParam: ignored return: 0 on success */ -#define PS_VOICE_DROPCALL "/Voice/DropCall" +#define PS_VOICE_DROPCALL "/Voice/DropCall" /* Service called to make the protocol hold a call. This means that the call should not @@ -140,7 +121,7 @@ wParam: (const char *) id lParam: ignored return: 0 on success */ -#define PS_VOICE_HOLDCALL "/Voice/HoldCall" +#define PS_VOICE_HOLDCALL "/Voice/HoldCall" /* Send a DTMF (one digit text) to a talking call. @@ -149,7 +130,7 @@ wParam: (const char *) id lParam: (TCHAR) dtmf return: 0 on success */ -#define PS_VOICE_SEND_DTMF "/Voice/SendDTMF" +#define PS_VOICE_SEND_DTMF "/Voice/SendDTMF" /* Used if protocol support VOICE_CALL_STRING. The call string is passed as @@ -159,7 +140,7 @@ wParam: (const TCHAR *) call string lParam: ignored return: 0 if wrong, 1 if correct */ -#define PS_VOICE_CALL_STRING_VALID "/Voice/CallStringValid" +#define PS_VOICE_CALL_STRING_VALID "/Voice/CallStringValid" /* Used if protocol support VOICE_CALL_CONTACT. @@ -171,10 +152,6 @@ wParam: (HANDLE) hContact lParam: (BOOL) TRUE if it is a test for 'can call now?', FALSE if is a test for 'will be possible to call someday?' return: 0 if can't be called, 1 if can */ -#define PS_VOICE_CALL_CONTACT_VALID "/Voice/CallContactValid" - - - - +#define PS_VOICE_CALL_CONTACT_VALID "/Voice/CallContactValid" #endif // __M_VOICE_H__ diff --git a/plugins/ExternalAPI/m_voiceservice.h b/plugins/ExternalAPI/m_voiceservice.h index c70dc8ea3e..a0fd124815 100644 --- a/plugins/ExternalAPI/m_voiceservice.h +++ b/plugins/ExternalAPI/m_voiceservice.h @@ -37,14 +37,13 @@ To get the devices for input/output and some options, query the db directly: struct VOICE_MODULE { - int cbSize; // sizeof(VOICE_MODULE) - TCHAR *description; // The description of the voice provider. This is the name that will be shown - // to the user - char *name; // The internal name of the voice provider. All PS_* serivces - // defined in m_voide.h need to be created based in this name. For example, - // PS_VOICE_CALL (/Voice/Call) need to be created as <name>/Voice/Call - char *icon; // Icon to identify provider (from icolib) - int flags; // or of VOICE_CAPS_*. You don't need to send VOICE_CAPS_VOICE. + int cbSize; // sizeof(VOICE_MODULE) + TCHAR *description; // The description of the voice provider. This is the name that will be shown to the user + char *name; // The internal name of the voice provider. All PS_* serivces + // defined in m_voice.h need to be created based in this name. For example, + // PS_VOICE_CALL (/Voice/Call) need to be created as <name>/Voice/Call + HANDLE icon; // Icon to identify provider (from icolib) + int flags; // or of VOICE_CAPS_*. You don't need to send VOICE_CAPS_VOICE. }; /* Register a new plugin that can make/receive voice calls (a voice provider). diff --git a/plugins/VoiceService/src/VoiceProvider.cpp b/plugins/VoiceService/src/VoiceProvider.cpp index b7a352036c..cbfcfa8f77 100644 --- a/plugins/VoiceService/src/VoiceProvider.cpp +++ b/plugins/VoiceService/src/VoiceProvider.cpp @@ -47,8 +47,8 @@ static int VoiceState(WPARAM wParam, LPARAM) return 0; call->AppendCallerID(in->hContact, - (in->flags & VOICE_UNICODE) ? in->pwszName : _A2T(in->pszName), - (in->flags & VOICE_UNICODE) ? in->pwszNumber : _A2T(in->pszNumber)); + (in->flags & VOICE_UNICODE) ? in->szName.w : _A2T(in->szName.a), + (in->flags & VOICE_UNICODE) ? in->szNumber.w : _A2T(in->szNumber.a)); call->secure = (in->flags & VOICE_SECURE) != 0; if (in->state == VOICE_STATE_RINGING && call->hContact != NULL) { @@ -74,18 +74,14 @@ static int VoiceState(WPARAM wParam, LPARAM) return 0; } -VoiceProvider::VoiceProvider(const char *name, const wchar_t *description, int flags, const char *icon) +VoiceProvider::VoiceProvider(const char *name, const wchar_t *description, int flags, HANDLE pIcon) : + hIcolib(pIcon) { strncpy(this->name, name, _countof(this->name)); this->name[_countof(this->name) - 1] = 0; lstrcpyn(this->description, description, _countof(this->description)); - if (icon == NULL) - this->icon[0] = 0; - else - lstrcpynA(this->icon, icon, _countof(this->icon)); - this->flags = flags; is_protocol = IsProtocol(name); canHold = (ProtoServiceExists(name, PS_VOICE_HOLDCALL) != 0); @@ -159,8 +155,8 @@ void VoiceProvider::Call(MCONTACT hContact, const wchar_t *number) HICON VoiceProvider::GetIcon() { - if (!IsEmptyA(icon)) - return IcoLib_GetIcon(icon); + if (hIcolib) + return IcoLib_GetIconByHandle(hIcolib); if (is_protocol) return Skin_LoadProtoIcon(name, ID_STATUS_ONLINE); @@ -170,9 +166,6 @@ HICON VoiceProvider::GetIcon() void VoiceProvider::ReleaseIcon(HICON hIcon) { - if (hIcon == NULL) - return; - - if (!IsEmptyA(icon)) + if (hIcolib) IcoLib_ReleaseIcon(hIcon); } diff --git a/plugins/VoiceService/src/main.cpp b/plugins/VoiceService/src/main.cpp index ce67916c9f..fd9062dfc2 100644 --- a/plugins/VoiceService/src/main.cpp +++ b/plugins/VoiceService/src/main.cpp @@ -30,7 +30,7 @@ PLUGININFOEX pluginInfoEx = __AUTHOR, __COPYRIGHT, __AUTHORWEB, - UNICODE_AWARE, + UNICODE_AWARE | STATIC_PLUGIN, { 0x1bfc449d, 0x8f6f, 0x4080, { 0x8f, 0x35, 0xf9, 0x40, 0xb3, 0xde, 0x12, 0x84 } } // {1BFC449D-8F6F-4080-8F35-F940B3DE1284} }; diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h index d54bf5ac13..22408dfe48 100644 --- a/plugins/VoiceService/src/stdafx.h +++ b/plugins/VoiceService/src/stdafx.h @@ -97,24 +97,24 @@ class VoiceProvider { public: wchar_t description[256]; - char name[256]; - char icon[256]; - int flags; - bool is_protocol; + char name[256]; + HANDLE hIcolib; + int flags; + bool is_protocol; - VoiceProvider(const char *name, const wchar_t *description, int flags, const char *icon); + VoiceProvider(const char *name, const wchar_t *description, int flags, HANDLE hIcolib); ~VoiceProvider(); - bool CanCall(const wchar_t *number); - bool CanCall(MCONTACT hContact, BOOL now = TRUE); - void Call(MCONTACT hContact, const wchar_t *number); + bool CanCall(const wchar_t *number); + bool CanCall(MCONTACT hContact, BOOL now = TRUE); + void Call(MCONTACT hContact, const wchar_t *number); - bool CanHold(); + bool CanHold(); - bool CanSendDTMF(); + bool CanSendDTMF(); HICON GetIcon(); - void ReleaseIcon(HICON hIcon); + void ReleaseIcon(HICON hIcon); private: bool canHold; |