00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _MW_SRVC_IM_H
00022 #define _MW_SRVC_IM_H
00023
00024
00025 #include <glib.h>
00026 #include "mw_common.h"
00027
00028
00041 #define mwService_IM 0x00001000
00042
00043
00048 struct mwServiceIm;
00049
00050
00054 struct mwConversation;
00055
00056
00057 enum mwImClientType {
00058 mwImClient_PLAIN = 0x00000001,
00059 mwImClient_NOTESBUDDY = 0x00033453,
00060 mwImClient_PRECONF = 0x00000019,
00061 mwImClient_UNKNOWN = 0xffffffff,
00062 };
00063
00064
00079 enum mwImSendType {
00080 mwImSend_PLAIN,
00081 mwImSend_TYPING,
00082 mwImSend_HTML,
00083 mwImSend_SUBJECT,
00084 mwImSend_MIME,
00085 };
00086
00087
00088
00090 enum mwConversationState {
00091 mwConversation_CLOSED,
00092 mwConversation_PENDING,
00093 mwConversation_OPEN,
00094 mwConversation_UNKNOWN,
00095 };
00096
00097
00098 #define mwConversation_isState(conv, state) \
00099 (mwConversation_getState(conv) == (state))
00100
00101 #define mwConversation_isClosed(conv) \
00102 mwConversation_isState((conv), mwConversation_CLOSED)
00103
00104 #define mwConversation_isPending(conv) \
00105 mwConversation_isState((conv), mwConversation_PENDING)
00106
00107 #define mwConversation_isOpen(conv) \
00108 mwConversation_isState((conv), mwConversation_OPEN)
00109
00110
00111
00114 struct mwImHandler {
00115
00117 void (*conversation_opened)(struct mwConversation *conv);
00118
00120 void (*conversation_closed)(struct mwConversation *conv, guint32 err);
00121
00123 void (*conversation_recv)(struct mwConversation *conv,
00124 enum mwImSendType type, gconstpointer msg);
00125
00128 void (*place_invite)(struct mwConversation *conv,
00129 const char *message,
00130 const char *title, const char *name);
00131
00133 void (*clear)(struct mwServiceIm *srvc);
00134 };
00135
00136
00137 struct mwServiceIm *mwServiceIm_new(struct mwSession *session,
00138 struct mwImHandler *handler);
00139
00140
00141 struct mwImHandler *mwServiceIm_getHandler(struct mwServiceIm *srvc);
00142
00143
00146 struct mwConversation *mwServiceIm_getConversation(struct mwServiceIm *srvc,
00147 struct mwIdBlock *target);
00148
00149
00151 struct mwConversation *mwServiceIm_findConversation(struct mwServiceIm *srvc,
00152 struct mwIdBlock *target);
00153
00154
00157 gboolean mwServiceIm_supports(struct mwServiceIm *srvc,
00158 enum mwImSendType type);
00159
00160
00168 void mwServiceIm_setClientType(struct mwServiceIm *srvc,
00169 enum mwImClientType type);
00170
00171
00172 enum mwImClientType mwServiceIm_getClientType(struct mwServiceIm *srvc);
00173
00174
00180 void mwConversation_open(struct mwConversation *conv);
00181
00182
00185 void mwConversation_close(struct mwConversation *conv, guint32 err);
00186
00187
00189 gboolean mwConversation_supports(struct mwConversation *conv,
00190 enum mwImSendType type);
00191
00192
00193 enum mwImClientType mwConversation_getClientType(struct mwConversation *conv);
00194
00195
00202 enum mwConversationState mwConversation_getState(struct mwConversation *conv);
00203
00204
00206 int mwConversation_send(struct mwConversation *conv,
00207 enum mwImSendType type, gconstpointer send);
00208
00209
00211 struct mwServiceIm *mwConversation_getService(struct mwConversation *conv);
00212
00213
00216 struct mwLoginInfo *mwConversation_getTargetInfo(struct mwConversation *conv);
00217
00218
00220 struct mwIdBlock *mwConversation_getTarget(struct mwConversation *conv);
00221
00222
00225 void mwConversation_setEncrypted(struct mwConversation *conv,
00226 gboolean useCipher);
00227
00228
00230 gboolean mwConversation_isEncrypted(struct mwConversation *conv);
00231
00232
00239 void mwConversation_setClientData(struct mwConversation *conv,
00240 gpointer data, GDestroyNotify clean);
00241
00242
00248 gpointer mwConversation_getClientData(struct mwConversation *conv);
00249
00250
00257 void mwConversation_removeClientData(struct mwConversation *conv);
00258
00259
00262 void mwConversation_free(struct mwConversation *conv);
00263
00264
00265 #endif
00266