From a36ca1b4d5d0c89b09382ac4215681b47865bea1 Mon Sep 17 00:00:00 2001 From: pescuma Date: Mon, 18 Jan 2010 00:53:43 +0000 Subject: sip_cli: Example plugin to use SIP client API git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@210 c086bb3d-8645-0410-b8da-73a8550f86e7 --- Plugins/sip_cli/sdk/m_sip.h | 98 +++++++++++++++++++ Plugins/sip_cli/sdk/m_voice.h | 180 +++++++++++++++++++++++++++++++++++ Plugins/sip_cli/sdk/m_voiceservice.h | 90 ++++++++++++++++++ 3 files changed, 368 insertions(+) create mode 100644 Plugins/sip_cli/sdk/m_sip.h create mode 100644 Plugins/sip_cli/sdk/m_voice.h create mode 100644 Plugins/sip_cli/sdk/m_voiceservice.h (limited to 'Plugins/sip_cli/sdk') diff --git a/Plugins/sip_cli/sdk/m_sip.h b/Plugins/sip_cli/sdk/m_sip.h new file mode 100644 index 0000000..360912b --- /dev/null +++ b/Plugins/sip_cli/sdk/m_sip.h @@ -0,0 +1,98 @@ +/* +Copyright (C) 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 __M_SIP_H__ +# define __M_SIP_H__ + + +// state is a VOICE_STATE_* +// flags are VOICE_* +// host_port can be NULL +typedef void (*SIPClientCallback)(void *param, int callId, int state, int flags, const TCHAR *host_port); + +struct SIP_REGISTRATION +{ + int cbSize; + const char *name; // Internal name of client + int udp_port; // UDP port to be used: 0 means random, -1 means don't want UDP + int tcp_port; // UDP port to be used: 0 means TCP, -1 means don't want TCP + int tls_port; // UDP port to be used: 0 means TLS, -1 means don't want TLS + + HANDLE hNetlib; // To be used for logs. Can be 0 + + SIPClientCallback callback; + void *callback_param; +}; + + +struct SIP_CLIENT +{ + void *data; // Do not touch + const TCHAR *host; + const int udp_port; + const int tcp_port; + const int tls_port; + + // @param protocol 1 UDP, 2 TCP, 3 TLS + // @return callId or <0 on error + int (*Call)(SIP_CLIENT *sip, const TCHAR *host, int port, int protocol); + + // @return 0 on success + int (*DropCall)(SIP_CLIENT *sip, int callId); + + // @return 0 on success + int (*HoldCall)(SIP_CLIENT *sip, int callId); + + // @return 0 on success + int (*AnswerCall)(SIP_CLIENT *sip, int callId); + + // @return 0 on success + int (*SendDTMF)(SIP_CLIENT *sip, int callId, TCHAR dtmf); +}; + + +/* +Register a SIP client, allowing it to make calls + +wParam = SIP_REGISTRATION * +lParam = 0 +return SIP_CLIENT * or NULL on error +*/ +#define MS_SIP_REGISTER "SIP/Client/Register" + + +/* +Unregister a SIP client and free the internal structures. + +wParam = SIP_CLIENT * +lParam = 0 +return 0 on success +*/ +#define MS_SIP_UNREGISTER "SIP/Client/Unregister" + + + + + + + + + +#endif // __M_SIP_H__ diff --git a/Plugins/sip_cli/sdk/m_voice.h b/Plugins/sip_cli/sdk/m_voice.h new file mode 100644 index 0000000..e4ea883 --- /dev/null +++ b/Plugins/sip_cli/sdk/m_voice.h @@ -0,0 +1,180 @@ +/* +Copyright (C) 2006-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_VOICE_H__ +# define __M_VOICE_H__ + + +#define EVENTTYPE_VOICE_CALL 8739 + + +#define VOICE_CAPS_VOICE (1<<0) // Voice is supported for this protocol. You need to set this one. +#define VOICE_CAPS_CALL_CONTACT (1<<1) // Set if a call can be made to a hContact (PS_VOICE_CALL_CONTACT_VALID is used to validate the string) +#define VOICE_CAPS_CALL_STRING (1<<3) // Set if a call can be made to some string (PS_VOICE_CALL_STRING_VALID is used to validate the string) +/* +Request to the protocol capabilities relative to voice. + +wParam: 0 +lParam: 0 +return: 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_STATE_TALKING 0 +#define VOICE_STATE_RINGING 1 +#define VOICE_STATE_CALLING 2 +#define VOICE_STATE_ON_HOLD 3 +#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 + + HANDLE 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; + }; + + + int state; // VOICE_STATE_* + +} VOICE_CALL; + + +/* +Notifies that a voice call changed state + +wParam: const VOICE_CALL * +lParam: ignored +return: 0 on success +*/ +#define PE_VOICE_CALL_STATE "/Voice/State" + + + +/* +Request the protocol to make a voice call + +wParam: (HANDLE) hContact +lParam: (const TCHAR *) number +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" + +/* +Service called to make the protocol answer a call or restore a hold call. +It is an async call. If the call was answered, the PE_VOICE_CALL_STATE +notification will be fired. + +wParam: (const char *) id +lParam: ignored +return: 0 on success +*/ +#define PS_VOICE_ANSWERCALL "/Voice/AnswerCall" + +/* +Service called to make the protocol answer a call. This can be called if the +call is ringing or has started. If called any other time it should be ignored. +It is an async call. If the call was droped, the PE_VOICE_CALL_STATE +notification will be fired. + +wParam: (const char *) id +lParam: ignored +return: 0 on success +*/ +#define PS_VOICE_DROPCALL "/Voice/DropCall" + +/* +Service called to make the protocol hold a call. This means that the call should not +be droped, but it should be muted and put in a hold, to allow other call to be answered. +If the protocol can't hold a cal, it should be droped. + +This can be called if the call has started. If called any other time it should be ignored. +It is an async call. If the call was droped, the PE_VOICE_CALL_STATE +notification will be fired. + +wParam: (const char *) id +lParam: ignored +return: 0 on success +*/ +#define PS_VOICE_HOLDCALL "/Voice/HoldCall" + +/* +Send a DTMF (one digit text) to a talking call. + +wParam: (const char *) id +lParam: (TCHAR) dtmf +return: 0 on success +*/ +#define PS_VOICE_SEND_DTMF "/Voice/SendDTMF" + +/* +Used if protocol support VOICE_CALL_STRING. The call string is passed as +wParam and the proto should validate it. If this service does not exist all numbers can be called. + +wParam: (const TCHAR *) call string +lParam: ignored +return: 0 if wrong, 1 if correct +*/ +#define PS_VOICE_CALL_STRING_VALID "/Voice/CallStringValid" + +/* +Used if protocol support VOICE_CALL_CONTACT. +The hContact is passed as wParam and the proto should tell if this contact can be +called. If this service does not exist all contacts can be called (or, if it is a protocol, +all contacts from the protocol can be called). + +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" + + + + + +#endif // __M_VOICE_H__ diff --git a/Plugins/sip_cli/sdk/m_voiceservice.h b/Plugins/sip_cli/sdk/m_voiceservice.h new file mode 100644 index 0000000..2d55d9a --- /dev/null +++ b/Plugins/sip_cli/sdk/m_voiceservice.h @@ -0,0 +1,90 @@ +/* +Copyright (C) 2007-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_VOICESERVICE_H__ +# define __M_VOICESERVICE_H__ + + +#define MIID_VOICESERVICE { 0x7d64437, 0xef2e, 0x4f60, { 0xbb, 0x2d, 0x3c, 0x51, 0x8f, 0xe2, 0x4d, 0x63 } } + + +/* +This services are a mirror of the services/notifications in m_voice.h, +with the difference that that ones are to be used by protocols, and this ones +are to be used by plugins that can make calls to contacts in multiple protocols. + +To get the devices for input/output and some options, query the db directly: + VoiceService/EchoCancelation BYTE default: TRUE + VoiceService/MicBoost BYTE default: TRUE + VoiceService/Input TString default: windows default + VoiceService/Output TString default: windows default +*/ + + +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 /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. +}; +/* +Register a new plugin that can make/receive voice calls (a voice provider). + +wParam: const VOICE_MODULE * +lParam: ignored +return: 0 on success +*/ +#define MS_VOICESERVICE_REGISTER "VoiceService/Register" + +/* +Unregister a plugin that can make/receive voice calls (a voice provider). + +wParam: (const char *) Provider name +lParam: ignored +return: 0 on success +*/ +#define MS_VOICESERVICE_UNREGISTER "VoiceService/Unregister" + +/* +Request a voice call to hContact. + +wParam: (HANDLE) hContact +lParam: ignored +return: the number of option calls for a contact. If > 0, it can be called +*/ +#define MS_VOICESERVICE_CAN_CALL "VoiceService/CanCall" + +/* +Request a voice call to hContact. + +wParam: (HANDLE) hContact +lParam: (char *) Voice provider or NULL to use any provider avaiable +return: 0 on success +*/ +#define MS_VOICESERVICE_CALL "VoiceService/Call" + + + +#endif // __M_VOICESERVICE_H__ -- cgit v1.2.3