adium: fix some #import paths
[siplcs.git] / src / miranda / miranda-private.h
blobed85525c8b2242327c1e60fc1b51a5ca646cd8f0
1 #ifdef _MSC_VER
2 #define __func__ __FUNCTION__
3 #endif
5 #define SIPSIMPLE_PROTOCOL_NAME LPGEN("Office Communicator")
6 #define SIP_UNIQUEID "sip_screenname"
8 #define SIPE_EVENTTYPE_ERROR_NOTIFY 2002
9 #define SIPE_DB_GETEVENTTEXT_ERROR_NOTIFY "SIP/SIMPLE/GetEventTextErrorNotify"
10 #define SIPE_EVENTTYPE_INFO_NOTIFY 2003
11 #define SIPE_DB_GETEVENTTEXT_INFO_NOTIFY "SIP/SIMPLE/GetEventTextInfoNotify"
12 #define SIPE_EVENTTYPE_IM_TOPIC 2010
13 #define SIPE_DB_GETEVENTTEXT_IM_TOPIC "SIP/SIMPLE/GetEventTextIMTopic"
15 #define SIPE_MIRANDA_IP_LOCAL 0
16 #define SIPE_MIRANDA_IP_MANUAL 1
17 #define SIPE_MIRANDA_IP_PROG 2
19 typedef enum
21 SIPE_MIRANDA_DISCONNECTED = 0, /**< Disconnected. */
22 SIPE_MIRANDA_CONNECTED, /**< Connected. */
23 SIPE_MIRANDA_CONNECTING /**< Connecting. */
25 } sipe_miranda_ConnectionState;
27 struct sipe_miranda_connection_info;
29 typedef struct sipe_backend_private
31 PROTO_INTERFACE proto;
32 struct sipe_core_public *sip;
33 CRITICAL_SECTION CriticalSection;
34 HANDLE m_hServerNetlibUser;
35 sipe_miranda_ConnectionState state;
36 gboolean valid;
37 gboolean disconnecting;
38 HANDLE disconnect_timeout;
39 GSList *contactMenuChatItems;
40 DWORD main_thread_id;
41 char _SIGNATURE[16];
42 } SIPPROTO;
44 struct sipe_backend_chat_session {
45 SIPPROTO *pr;
46 gchar *conv;
49 typedef enum
51 SIPE_MIRANDA_INPUT_READ = 1 << 0, /**< A read condition. */
52 SIPE_MIRANDA_INPUT_WRITE = 1 << 1 /**< A write condition. */
54 } sipe_miranda_input_condition;
56 /** The type of callbacks to handle events on file descriptors, as passed to
57 * sipe_miranda_input_add(). The callback will receive the @c user_data
58 * passed to sipe_miranda_input_add(), the file descriptor on which the event
59 * occurred, and the condition that was satisfied to cause the callback to be
60 * invoked.
62 typedef void (*sipe_miranda_input_function)(gpointer, gint, sipe_miranda_input_condition);
64 typedef struct sipe_miranda_sel_entry;
66 #define CONTACTS_FOREACH(list) { \
67 GSList *entry = list; \
68 while (entry) { \
69 HANDLE hContact = entry->data; \
70 entry = entry->next;
71 #define CONTACTS_FOREACH_END }}
74 typedef INT_PTR (*SipSimpleServiceFunc)( SIPPROTO*, WPARAM, LPARAM );
75 typedef int (*SipSimpleEventFunc)( SIPPROTO*, WPARAM, LPARAM );
76 typedef void (*SipSimpleThreadFunc)( SIPPROTO*, void* );
78 #define _NI(string) SIPE_DEBUG_INFO( "%s:%s (%d) ##NOT IMPLEMENTED## %s", __FILE__, __FUNCTION__, __LINE__, #string )
79 #define _NIF() _NI("")
81 #define _LOCK(crit) do { SIPE_DEBUG_INFO("[L:%08x] About to lock", crit); EnterCriticalSection(crit); SIPE_DEBUG_INFO("[L:%08x] Locked", crit); } while (0)
82 #define _UNLOCK(crit) do { SIPE_DEBUG_INFO("[L:%08x] About to unlock", crit); LeaveCriticalSection(crit); SIPE_DEBUG_INFO("[L:%08x] Unlocked", crit); } while (0)
83 #define LOCK _LOCK(&pr->CriticalSection)
84 #define UNLOCK _UNLOCK(&pr->CriticalSection)
86 #define _TRACE do { SIPE_DEBUG_INFO_NOFORMAT("TRACE") } while (0);
88 void sipe_miranda_close( SIPPROTO *pr);
90 TCHAR* CHAR2TCHAR( const char *chr );
91 char* TCHAR2CHAR( const TCHAR *tchr );
92 HANDLE sipe_miranda_AddEvent(const SIPPROTO *pr, HANDLE hContact, WORD wType, DWORD dwTime, DWORD flags, DWORD cbBlob, PBYTE pBlob);
94 gchar* sipe_miranda_getContactString(const SIPPROTO *pr, HANDLE hContact, const gchar* name);
95 gchar* sipe_miranda_getString(const SIPPROTO *pr, const gchar* name);
96 int sipe_miranda_getStaticString(const SIPPROTO *pr, HANDLE hContact, const gchar* valueName, gchar* dest, unsigned dest_len);
97 gchar* sipe_miranda_getGlobalString(const gchar* name);
98 WORD sipe_miranda_getGlobalWord(const gchar* name, WORD* rv);
99 WORD sipe_miranda_getWord(const SIPPROTO *pr, HANDLE hContact, const gchar* name, WORD* rv);
100 DWORD sipe_miranda_getDword( const SIPPROTO *pr, HANDLE hContact, const gchar* name, DWORD* rv);
101 gboolean sipe_miranda_getBool(const SIPPROTO *pr, const gchar *name, gboolean defval);
103 void sipe_miranda_setContactString(const SIPPROTO *pr, HANDLE hContact, const gchar* name, const gchar* value);
104 void sipe_miranda_setContactStringUtf(const SIPPROTO *pr, HANDLE hContact, const gchar* valueName, const gchar* parValue );
105 void sipe_miranda_setString(const SIPPROTO *pr, const gchar* name, const gchar* value);
106 void sipe_miranda_setStringUtf(const SIPPROTO *pr, const gchar* name, const gchar* value);
107 void sipe_miranda_setGlobalString(const gchar* name, const gchar* value);
108 void sipe_miranda_setGlobalStringUtf(const gchar* valueName, const gchar* parValue );
109 int sipe_miranda_setGlobalWord(const gchar* szSetting, WORD wValue);
110 int sipe_miranda_setWord(const SIPPROTO *pr, HANDLE hContact, const gchar* szSetting, WORD wValue);
111 int sipe_miranda_setBool(const SIPPROTO *pr, const gchar *name, gboolean value);
113 struct sipe_miranda_sel_entry* sipe_miranda_input_add(HANDLE fd, sipe_miranda_input_condition cond, sipe_miranda_input_function func, gpointer user_data);
114 gboolean sipe_miranda_input_remove(struct sipe_miranda_sel_entry *entry);
116 int sipe_miranda_SendBroadcast(SIPPROTO *pr, HANDLE hContact,int type,int result,HANDLE hProcess,LPARAM lParam);
117 void sipe_miranda_SendProtoAck( SIPPROTO *pr, HANDLE hContact, DWORD dwCookie, int nAckResult, int nAckType, const char* pszMessage);
118 void sipe_miranda_msgbox(const char *msg, const char *caption);
119 gchar *sipe_miranda_uri_self(SIPPROTO *pr);
121 void sipe_miranda_login(SIPPROTO *pr);
122 struct sipe_miranda_connection_info *sipe_miranda_connect(SIPPROTO *pr, const gchar *host, int port, gboolean tls, int timeout, void (*callback)(HANDLE fd, void *data, const gchar *reason), void *data);
123 gboolean sipe_miranda_cmd(gchar *cmd, gchar *buf, DWORD *maxlen);
125 gchar* sipe_miranda_eliminate_html(const gchar *string, int len);
126 gchar* sipe_miranda_html2rtf(const gchar *text);
127 unsigned short sipe_miranda_network_get_port_from_fd( HANDLE fd );
128 const gchar *sipe_miranda_get_local_ip(void);
129 void sipe_miranda_connection_destroy(SIPPROTO *pr);
130 void sipe_miranda_connection_error_reason(SIPPROTO *pr, sipe_connection_error error, const gchar *msg);
131 gpointer sipe_miranda_schedule_mseconds(void (*callback)(gpointer), guint timeout, gpointer data);
133 /* Buddy utility functions */
134 sipe_backend_buddy sipe_miranda_buddy_find(SIPPROTO *pr, const gchar *name, const gchar *group);
135 GSList* sipe_miranda_buddy_find_all(SIPPROTO *pr, const gchar *buddy_name, const gchar *group_name);
137 /* Plugin interface functions */
138 int sipe_miranda_SetStatus( SIPPROTO *pr, int iNewStatus );
139 int sipe_miranda_SendMsg(SIPPROTO *pr, HANDLE hContact, int flags, const char* msg);
140 int sipe_miranda_RecvMsg(SIPPROTO *pr, HANDLE hContact, PROTORECVEVENT* pre);
141 int sipe_miranda_SetAwayMsg(SIPPROTO *pr, int m_iStatus, const PROTOCHAR* msg);
142 HANDLE sipe_miranda_GetAwayMsg( SIPPROTO *pr, HANDLE hContact );
143 HANDLE sipe_miranda_SendFile( SIPPROTO *pr, HANDLE hContact, const PROTOCHAR* szDescription, PROTOCHAR** ppszFiles );
144 int sipe_miranda_RecvFile( SIPPROTO *pr, HANDLE hContact, PROTOFILEEVENT* evt );
145 int sipe_miranda_FileDeny( SIPPROTO *pr, HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason );
146 HANDLE sipe_miranda_FileAllow( SIPPROTO *pr, HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath );
147 int sipe_miranda_UserIsTyping( SIPPROTO *pr, HANDLE hContact, int type );
148 int sipe_miranda_GetInfo( SIPPROTO *pr, HANDLE hContact, int infoType );
149 HANDLE sipe_miranda_SearchByEmail( SIPPROTO *pr, const PROTOCHAR* email );
150 HANDLE sipe_miranda_SearchByName( SIPPROTO *pr, const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName);
151 HWND sipe_miranda_SearchAdvanced( SIPPROTO *pr, HWND owner );
153 /* Plugin event functions */
154 int sipe_miranda_buddy_delete(SIPPROTO *pr, WPARAM wParam, LPARAM lParam);
156 int SipeStatusToMiranda(guint activity);
157 guint MirandaStatusToSipe(int status);