| channel.h | | channel.h | |
| | | | |
| #ifndef _MW_CHANNEL_H | | #ifndef _MW_CHANNEL_H | |
| #define _MW_CHANNEL_H | | #define _MW_CHANNEL_H | |
| | | | |
| #include <glib.h> | | #include <glib.h> | |
| #include <glib/gslist.h> | | #include <glib/gslist.h> | |
| #include <time.h> | | #include <time.h> | |
| #include "common.h" | | #include "common.h" | |
| | | | |
|
| | | /* place-holders */ | |
| struct mwSession; | | struct mwSession; | |
| struct mwMsgChannelCreate; | | struct mwMsgChannelCreate; | |
| struct mwMsgChannelAccept; | | struct mwMsgChannelAccept; | |
| struct mwMsgChannelDestroy; | | struct mwMsgChannelDestroy; | |
| struct mwMsgChannelSend; | | struct mwMsgChannelSend; | |
| | | | |
|
| /* this should never ever need to change, but just in case... */ | | /** @file channel.h | |
| #define MASTER_CHANNEL_ID 0x00000000 | | | |
| | | | |
|
| /* 1 if a channel id appears to be that of an incoming channel, or 0 if not | | Life-cycle of an outgoing channel: | |
| */ | | | |
| #define CHAN_ID_IS_INCOMING(id) \ | | | |
| (0x80000000 & (id)) | | | |
| | | | |
|
| /* 1 if a channel id appears to be that of an outgoing channel, or 0 if not | | 1: mwChannel_new is called. If there is a channel in the outgoing | |
| */ | | collection in state NEW, then it is returned. Otherwise, a channel | |
| #define CHAN_ID_IS_OUTGOING(id) \ | | is allocated, assigned a unique outgoing id, marked as NEW, and | |
| (! CHAN_ID_IS_INCOMING(id)) | | returned. | |
| | | | |
|
| /* 1 if a channel appears to be an incoming channel, or 0 if not */ | | 2: channel is set to INIT status (effectively earmarking it as in | |
| #define CHAN_IS_INCOMING(chan) \ | | use). fields on the channel can then be set as necessary to | |
| CHAN_ID_IS_INCOMING((chan)->id) | | prepare it for creation. | |
| | | | |
|
| /* 1 if a channel appears to be an outgoing channel, or 0 if not */ | | 3: mwChannel_create is called. The channel is marked to WAIT status | |
| #define CHAN_IS_OUTGOING(chan) \ | | and a message is sent to the server. The channel is also marked as | |
| CHAN_ID_IS_OUTGOING((chan)->id) | | inactive as of that moment. | |
| | | | |
|
| /* Life-cycle of an outgoing channel: | | 4: the channel is accepted (step 5) or rejected (step 7) | |
| | | | |
|
| 1: mwChannel_new is called. If there is a channel in the outgoing | | 5: an accept message is received from the server, and the channel | |
| collection in state NEW, then it is returned. Otherwise, a channel | | is marked as OPEN, and the inactive mark is removed. And messages | |
| is allocated, assigned a unique outgoing id, marked as NEW, and | | in the in or out queues for that channel are processed. The channel | |
| returned. | | is now ready to be used. | |
| | | | |
|
| 2: channel is set to INIT status (effectively earmarking it as in | | 6: data is sent and received over the channel | |
| use). fields on the channel can then be set as necessary to | | | |
| prepare it for creation. | | | |
| | | | |
|
| 3: mwChannel_create is called. The channel is marked to WAIT status | | 7: the channel is closed either by receipt of a close message or by | |
| and a message is sent to the server. The channel is also marked as | | local action. If by local action, then a close message is sent to | |
| inactive as of that moment. | | the server. The channel is cleaned up, its queues dumped, and it | |
| | | is set to NEW status to await re-use. | |
| | | | |
|
| 4: the channel is accepted (step 5) or rejected (step 7) | | Life-cycle of an incoming channel: | |
| | | | |
|
| 5: an accept message is received from the server, and the channel | | 1: a channel create message is received. A channel is allocated and | |
| is marked as OPEN, and the inactive mark is removed. And messages | | given an id matching the message. It is placed in status WAIT, and | |
| in the in or out queues for that channel are processed. The channel | | marked as inactive as of that moment. The service matching that | |
| is now ready to be used. | | channel is alerted of the incoming creation request. | |
| | | | |
|
| 6: data is sent and received over the channel | | 2: the service can either accept (step 3) or reject (step 5) the | |
| | | channel | |
| | | | |
|
| 7: the channel is closed either by receipt of a close message or by | | 3: mwChannel_accept is called. The channel is marked as OPEN, and | |
| local action. If by local action, then a close message is sent to | | an accept message is sent to the server. And messages in the in or | |
| the server. The channel is cleaned up, its queues dumped, and it | | out queues for that channel are processed. The channel is now ready | |
| is set to NEW status to await re-use. | | to be used. | |
| | | | |
|
| Life-cycle of an incoming channel: | | 4: data is sent and received over the channel | |
| | | | |
|
| 1: a channel create message is received. A channel is allocated and | | 5: The channel is closed either by receipt of a close message or by | |
| given an id matching the message. It is placed in status WAIT, and | | local action. If by local action, then a close message is sent to | |
| marked as inactive as of that moment. The service matching that | | the server. The channel is cleaned up, its queues dumped, and it | |
| channel is alerted of the incoming creation request. | | is deallocated. */ | |
| | | | |
|
| 2: the service can either accept (step 3) or reject (step 5) the | | /** this should never ever need to change, but just in case... */ | |
| channel | | #define MASTER_CHANNEL_ID 0x00000000 | |
| | | | |
|
| 3: mwChannel_accept is called. The channel is marked as OPEN, and | | #ifndef MAX_INACTIVE_KILLS | |
| an accept message is sent to the server. And messages in the in or | | /** Max inactive channels to destroy in a single call. Used in | |
| out queues for that channel are processed. The channel is now ready | | mwChannelSet_destroyInactive to determine how many inactive | |
| to be used. | | channels are collected for destruction. 32 is a big number for a | |
| | | single client */ | |
| | | #define MAX_INACTIVE_KILLS 32 | |
| | | #endif | |
| | | | |
|
| 4: data is sent and received over the channel | | /** 1 if a channel id appears to be that of an incoming channel, or 0 if no | |
| | | t */ | |
| | | #define CHAN_ID_IS_INCOMING(id) \ | |
| | | (0x80000000 & (id)) | |
| | | | |
|
| 5: The channel is closed either by receipt of a close message or by | | /** 1 if a channel id appears to be that of an outgoing channel, or 0 if no | |
| local action. If by local action, then a close message is sent to | | t */ | |
| the server. The channel is cleaned up, its queues dumped, and it | | #define CHAN_ID_IS_OUTGOING(id) \ | |
| is deallocated. */ | | (! CHAN_ID_IS_INCOMING(id)) | |
| | | | |
| | | /** 1 if a channel appears to be an incoming channel, or 0 if not */ | |
| | | #define CHAN_IS_INCOMING(chan) \ | |
| | | CHAN_ID_IS_INCOMING((chan)->id) | |
| | | | |
| | | /** 1 if a channel appears to be an outgoing channel, or 0 if not */ | |
| | | #define CHAN_IS_OUTGOING(chan) \ | |
| | | CHAN_ID_IS_OUTGOING((chan)->id) | |
| | | | |
| | | /** @struct mwChannelSet | |
| | | Collection of channels. */ | |
| | | struct mwChannelSet { | |
| | | struct mwSession *session; | |
| | | GList *outgoing; | |
| | | GList *incoming; | |
| | | }; | |
| | | | |
| | | /** channel status */ | |
| enum mwChannelStatus { | | enum mwChannelStatus { | |
| mwChannel_NEW = 0x00, | | mwChannel_NEW = 0x00, | |
| mwChannel_INIT = 0x01, | | mwChannel_INIT = 0x01, | |
| mwChannel_WAIT = 0x10, | | mwChannel_WAIT = 0x10, | |
| mwChannel_OPEN = 0x80 | | mwChannel_OPEN = 0x80 | |
| }; | | }; | |
| | | | |
| struct mwChannel { | | struct mwChannel { | |
| | | | |
|
| /* session this channel belongs to */ | | /** session this channel belongs to */ | |
| struct mwSession *session; | | struct mwSession *session; | |
| | | | |
| enum mwChannelStatus status; | | enum mwChannelStatus status; | |
| | | | |
|
| /* timestamp when channel was marked as inactive. */ | | /** timestamp when channel was marked as inactive. */ | |
| unsigned int inactive; | | unsigned int inactive; | |
| | | | |
|
| /* creator for incoming channel, target for outgoing channel */ | | /** creator for incoming channel, target for outgoing channel */ | |
| struct mwIdBlock user; | | struct mwIdBlock user; | |
| | | | |
| /* similar to data from the CreateCnl message in 8.4.1.7 */ | | /* similar to data from the CreateCnl message in 8.4.1.7 */ | |
| guint32 reserved; | | guint32 reserved; | |
| guint32 id; | | guint32 id; | |
| guint32 service; | | guint32 service; | |
| guint32 proto_type; | | guint32 proto_type; | |
| guint32 proto_ver; | | guint32 proto_ver; | |
| | | | |
|
| /* encryption information from the channel create message */ | | /** encryption information from the channel create message */ | |
| struct mwEncryptBlock encrypt; | | struct mwEncryptBlock encrypt; | |
| | | | |
|
| /* the expanded rc2/40 key for receiving encrypted messages */ | | /** the expanded rc2/40 key for receiving encrypted messages */ | |
| int incoming_key[64]; | | int incoming_key[64]; | |
|
| char outgoing_iv[8]; /* iv for outgoing messages */ | | char outgoing_iv[8]; /**< iv for outgoing messages */ | |
| char incoming_iv[8]; /* iv for incoming messages */ | | char incoming_iv[8]; /**< iv for incoming messages */ | |
| | | | |
|
| GSList *outgoing_queue; /* queued outgoing messages */ | | GSList *outgoing_queue; /**< queued outgoing messages */ | |
| GSList *incoming_queue; /* queued incoming messages */ | | GSList *incoming_queue; /**< queued incoming messages */ | |
| | | | |
|
| /* optional slot for attaching an extra bit of state, usually by the | | /** optional slot for attaching an extra bit of state, usually by | |
| owning service */ | | the owning service */ | |
| void *addtl; | | void *addtl; | |
| | | | |
|
| /* optional cleanup function. Useful for ensuring proper cleanup of | | /** optional cleanup function. Useful for ensuring proper cleanup of | |
| an attached value in the addtl slot. */ | | an attached value in the addtl slot. */ | |
| void (*clear)(struct mwChannel *); | | void (*clear)(struct mwChannel *); | |
| }; | | }; | |
| | | | |
|
| struct mwChannelSet { | | /** Allocate and initialize a channel set for a session */ | |
| struct mwSession *session; | | struct mwChannelSet *mwChannelSet_new(struct mwSession *); | |
| GList *outgoing; | | | |
| GList *incoming; | | | |
| }; | | | |
| | | | |
|
| void mwChannelSet_clear(struct mwChannelSet *); | | /** Clear and deallocate a channel set */ | |
| | | void mwChannelSet_free(struct mwChannelSet *); | |
| | | | |
|
| | | /** intended to be called periodically to close channels which have | |
| | | been marked as inactive since before the threshold timestamp. */ | |
| | | void mwChannelSet_destroyInactive(struct mwChannelSet *, time_t thrsh); | |
| | | | |
| | | /** Create a new incoming channel with the given channel id */ | |
| struct mwChannel *mwChannel_newIncoming(struct mwChannelSet *, guint32 id); | | struct mwChannel *mwChannel_newIncoming(struct mwChannelSet *, guint32 id); | |
| | | | |
|
| | | /** Create a new outgoing channel. Its channel ID will be generated by | |
| | | the owning channel set */ | |
| struct mwChannel *mwChannel_newOutgoing(struct mwChannelSet *); | | struct mwChannel *mwChannel_newOutgoing(struct mwChannelSet *); | |
| | | | |
|
| /* for outgoing channels: instruct the session to send a channel | | /** marks a channel as active or inactive. | |
| create message to the server, and to mark the channel (which must | | @param chan The channel to mark | |
| be in INIT status) as being in WAIT status. | | @param active TRUE to mark the channel as active, FALSE to mark it | |
| | | as inactive | |
| | | */ | |
| | | void mwChannel_markActive(struct mwChannel *chan, gboolean active); | |
| | | | |
|
| for incoming channels: configures the channel according to options | | /** Formally open a channel. | |
| in the channel create message. Marks the channel as being in WAIT | | | |
| status */ | | | |
| int mwChannel_create(struct mwChannel *, struct mwMsgChannelCreate *); | | | |
| | | | |
|
| /* for outgoing channels: receives the acceptance message and marks | | For outgoing channels: instruct the session to send a channel | |
| the channel as being OPEN. | | create message to the server, and to mark the channel (which must | |
| | | be in INIT status) as being in WAIT status. | |
| | | | |
|
| for incoming channels: instruct the session to send a channel | | For incoming channels: configures the channel according to options | |
| accept message to the server, and to mark the channel (which must | | in the channel create message. Marks the channel as being in WAIT | |
| be an incoming channel in WAIT status) as being OPEN. */ | | status */ | |
| int mwChannel_accept(struct mwChannel *, struct mwMsgChannelAccept *); | | int mwChannel_create(struct mwChannel *chan, | |
| | | struct mwMsgChannelCreate *msg); | |
| | | | |
|
| /* instruct the session to destroy a channel. The channel may be | | /** Formally accept a channel. | |
| either incoming or outgoing, but must be in WAIT or OPEN status. */ | | | |
| int mwChannel_destroy(struct mwChannel *, struct mwMsgChannelDestroy *); | | | |
| | | | |
|
| /* lookup a channel by its id, compose a channel destroy message with | | For outgoing channels: receives the acceptance message and marks | |
| the passed reason and text, and send it via mwChannel_destroy */ | | the channel as being OPEN. | |
| int mwChannel_destroyQuick(struct mwChannelSet *, guint32 chan, | | | |
| guint32 reason, const char *text); | | | |
| | | | |
|
| /* compose a sendOnCnl message, encrypt it as per the channel's | | For incoming channels: instruct the session to send a channel | |
| specification, and send it */ | | accept message to the server, and to mark the channel (which must | |
| int mwChannel_send(struct mwChannel *, guint32 msg_type, | | be an incoming channel in WAIT status) as being OPEN. */ | |
| const char *, gsize); | | int mwChannel_accept(struct mwChannel *, struct mwMsgChannelAccept *); | |
| | | | |
|
| void mwChannel_recv(struct mwChannel *, struct mwMsgChannelSend *); | | /** Formally destroy a channel. The channel may be either incoming or | |
| | | outgoing, but must be in WAIT or OPEN status. */ | |
| | | int mwChannel_destroy(struct mwChannel *chan, | |
| | | struct mwMsgChannelDestroy *msg); | |
| | | | |
|
| /* locate a channel by its id. */ | | /** Destroy a channel. Composes and sends channel destroy message with | |
| struct mwChannel *mwChannel_find(struct mwChannelSet *, guint32 chan); | | the passed reason, and send it via mwChannel_destroy. Has no | |
| | | effect if chan is NULL. | |
| | | | |
|
| /* used in destroyInactiveChannels to determine how many inactive | | @returns value of mwChannel_destroy call, or zero if chan is NULL | |
| channels can be destroyed in a single call. 32 is a big number for | | */ | |
| a single client */ | | int mwChannel_destroyQuick(struct mwChannel *chan, guint32 reason); | |
| #define MAX_INACTIVE_KILLS 32 | | | |
| | | | |
|
| /* intended to be called periodically to close channels which have | | /** Compose a send-on-channel message, encrypt it as per the channel's | |
| been marked as inactive since before the threshold timestamp. */ | | specification, and send it */ | |
| void mwChannelSet_destroyInactive(struct mwChannelSet *, time_t thrsh); | | int mwChannel_send(struct mwChannel *chan, guint32 msg_type, | |
| | | const char *buf, gsize len); | |
| | | | |
| | | /** Feed data into a channel. */ | |
| | | void mwChannel_recv(struct mwChannel *chan, struct mwMsgChannelSend *msg); | |
| | | | |
| | | /** Obtain a reference to a channel by its id. | |
| | | @returns the channel matching chan, or NULL */ | |
| | | struct mwChannel *mwChannel_find(struct mwChannelSet *cs, guint32 chan); | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 44 change blocks. |
| 106 lines changed or deleted | | 141 lines changed or added | |
|
| common.h | | common.h | |
| | | | |
| #ifndef _MW_COMMON_H_ | | #ifndef _MW_COMMON_H_ | |
| #define _MW_COMMON_H_ | | #define _MW_COMMON_H_ | |
| | | | |
| #include <glib.h> | | #include <glib.h> | |
| | | | |
|
| /* 8.1 Basic Data Types */ | | /** @file common.h | |
| | | | |
| int guint16_put(gchar **b, gsize *n, guint val); | | | |
| | | | |
| int guint16_get(gchar **b, gsize *n, guint *val); | | | |
| | | | |
| guint guint16_peek(const gchar *b, gsize n); | | | |
| | | | |
| int guint32_put(gchar **b, gsize *n, guint val); | | | |
| | | | |
|
| int guint32_get(gchar **b, gsize *n, guint *val); | | Functions in this file all fit into similar naming conventions of | |
| | | <code>TYPE_ACTION</code> as per the activity they perform. The | |
| | | following actions are available: | |
| | | | |
|
| guint guint32_peek(const gchar *b, gsize n); | | <code>gsize TYPE_buflen(TYPE val)</code> - calculates the | |
| | | necessary length in bytes required to serialize val. | |
| | | | |
|
| int gboolean_put(gchar **b, gsize *n, gboolean val); | | <code>int TYPE_put(char **b, gsize *n, TYPE *val)</code> - | |
| | | marshalls val onto the buffer portion b, which has n bytes | |
| | | remaining. b will be incremented forward along the buffer, and n | |
| | | will be decremented by the number of bytes written. returns 0 for | |
| | | success, and non-zero for failure. Failure is usually attributed | |
| | | to an insufficiently large n (indicating not enough buffer | |
| | | remaining). For guint16, guint32, and gboolean, <code>TYPE | |
| | | val</code> is used instead of <code>TYPE *val</code>. | |
| | | | |
|
| int gboolean_get(gchar **b, gsize *n, gboolean *val); | | <code>int TYPE_get(char **b, gsize *n, TYPE *val)</code> - | |
| | | unmarshals val from the buffer portion b, which has n bytes | |
| | | remaining. b will be incremented forward along the buffer, and n | |
| | | will be decremented by the number of bytes read. returns 0 for | |
| | | success, and non-zero for failure. Failure is usually attributed | |
| | | to an insufficiently large n (indicating not enough buffer | |
| | | remaining for the type to be complete). | |
| | | | |
|
| gboolean gboolean_peek(const gchar *b, gsize n); | | <code>void TYPE_clear(TYPE *val)</code> - zeros and frees internal | |
| | | members of val, but does not free val itself. Needs to be called | |
| | | before free-ing any complex types which have been unmarshalled | |
| | | from a TYPE_get or populated from a TYPE_clone call to prevent | |
| | | memory leaks. | |
| | | | |
|
| /* strings are normally NULL-terminated, but when written to a message then | | <code>void TYPE_clone(TYPE *to, TYPE *from)</code> - copies/clones | |
| are not. Instead, they have a two-byte length prefix. */ | | members of from into to. May result in memory allocation for some | |
| gsize mwString_buflen(const gchar *str); | | types. Note that to is not cleared before-hand, it must already be | |
| | | in a pristine condition. | |
| | | | |
|
| int mwString_put(gchar **b, gsize *n, const gchar *str); | | <code>gboolean TYPE_equal(TYPE *y, TYPE *z)</code> - simple | |
| | | equality test. | |
| | | | |
|
| int mwString_get(gchar **b, gsize *n, gchar **str); | | */ | |
| | | | |
| struct mwOpaque { | | struct mwOpaque { | |
|
| gsize len; /* four byte unsigned integer: length of data. */ | | gsize len; /**< four byte unsigned integer: length of data. */ | |
| gchar *data; /* data. normally no NULL termination */ | | char *data; /**< data. normally no NULL termination */ | |
| }; | | }; | |
| | | | |
|
| gsize mwOpaque_buflen(struct mwOpaque *o); | | | |
| | | | |
| int mwOpaque_put(gchar **b, gsize *n, struct mwOpaque *o); | | | |
| | | | |
| int mwOpaque_get(gchar **b, gsize *n, struct mwOpaque *o); | | | |
| | | | |
| void mwOpaque_clear(struct mwOpaque *o); | | | |
| | | | |
| void mwOpaque_clone(struct mwOpaque *to, struct mwOpaque *from); | | | |
| | | | |
| /* 8.3.6 Login Types */ | | /* 8.3.6 Login Types */ | |
| | | | |
| enum mwLoginType { | | enum mwLoginType { | |
| mwLogin_LIB = 0x1000, | | mwLogin_LIB = 0x1000, | |
| mwLogin_JAVA_WEB = 0x1001, | | mwLogin_JAVA_WEB = 0x1001, | |
| mwLogin_BINARY = 0x1002, | | mwLogin_BINARY = 0x1002, | |
|
| mwLogin_JAVA_APP = 0x1003 | | mwLogin_JAVA_APP = 0x1003, | |
| | | mwLogin_MEANWHILE = 0x1700 | |
| }; | | }; | |
| | | | |
| /* 8.2 Common Structures */ | | /* 8.2 Common Structures */ | |
| /* 8.2.1 Login Info block */ | | /* 8.2.1 Login Info block */ | |
| | | | |
| struct mwLoginInfo { | | struct mwLoginInfo { | |
|
| gchar *login_id; /* community-unique ID of the login */ | | char *login_id; /**< community-unique ID of the login */ | |
| enum mwLoginType type; /* type of login (see 8.3.6) */ | | enum mwLoginType type; /**< type of login (see 8.3.6) */ | |
| gchar *user_id; /* community-unique ID of the user */ | | char *user_id; /**< community-unique ID of the user */ | |
| gchar *user_name; /* name of user (nick name, full name, etc) */ | | char *user_name; /**< name of user (nick name, full name, etc) */ | |
| gchar *community; /* community name (usually domain name) */ | | char *community; /**< community name (usually domain name) */ | |
| gboolean full; /* if FALSE, following fields non-existant */ | | gboolean full; /**< if FALSE, following fields non-existant */ | |
| gchar *desc; /* implementation defined description */ | | char *desc; /**< implementation defined description */ | |
| guint ip_addr; /* ip addr of the login */ | | guint ip_addr; /**< ip addr of the login */ | |
| gchar *server_id; /* unique ID of login's server */ | | char *server_id; /**< unique ID of login's server */ | |
| }; | | }; | |
| | | | |
|
| gsize mwLoginInfo_buflen(struct mwLoginInfo *info); | | | |
| | | | |
| int mwLoginInfo_put(gchar **b, gsize *n, struct mwLoginInfo *info); | | | |
| | | | |
| int mwLoginInfo_get(gchar **b, gsize *n, struct mwLoginInfo *info); | | | |
| | | | |
| void mwLoginInfo_clear(struct mwLoginInfo *info); | | | |
| | | | |
| void mwLoginInfo_clone(struct mwLoginInfo *to, struct mwLoginInfo *from); | | | |
| | | | |
| /* 8.2.2 Private Info Block */ | | /* 8.2.2 Private Info Block */ | |
| | | | |
| struct mwUserItem { | | struct mwUserItem { | |
|
| gboolean full; /* if FALSE, don't include name */ | | gboolean full; /**< if FALSE, don't include name */ | |
| gchar *id; /* user id */ | | char *id; /**< user id */ | |
| gchar *name; /* user name */ | | char *name; /**< user name */ | |
| }; | | }; | |
| | | | |
|
| gsize mwUserItem_buflen(struct mwUserItem *user); | | | |
| | | | |
| int mwUserItem_put(gchar **b, gsize *n, struct mwUserItem *user); | | | |
| | | | |
| int mwUserItem_get(gchar **b, gsize *n, struct mwUserItem *user); | | | |
| | | | |
| void mwUserItem_clear(struct mwUserItem *user); | | | |
| | | | |
| struct mwPrivacyInfo { | | struct mwPrivacyInfo { | |
|
| guint reserved; /* reserved for internal use */ | | guint reserved; /**< reserved for internal use */ | |
| gboolean deny; /* deny (true) or allow (false) users */ | | gboolean deny; /**< deny (true) or allow (false) users */ | |
| guint count; /* count of following users list */ | | guint count; /**< count of following users list */ | |
| struct mwUserItem *users; /* the users list */ | | struct mwUserItem *users; /**< the users list */ | |
| }; | | }; | |
| | | | |
|
| gsize mwPrivacyInfo_buflen(struct mwPrivacyInfo *info); | | | |
| | | | |
| int mwPrivacyInfo_put(gchar **b, gsize *n, struct mwPrivacyInfo *info); | | | |
| | | | |
| int mwPrivacyInfo_get(gchar **b, gsize *n, struct mwPrivacyInfo *info); | | | |
| | | | |
| void mwPrivacyInfo_clear(struct mwPrivacyInfo *info); | | | |
| | | | |
| /* 8.3.5 User Status Types */ | | /* 8.3.5 User Status Types */ | |
| | | | |
| enum mwStatusType { | | enum mwStatusType { | |
| mwStatus_ACTIVE = 0x0020, | | mwStatus_ACTIVE = 0x0020, | |
| mwStatus_IDLE = 0x0040, | | mwStatus_IDLE = 0x0040, | |
| mwStatus_AWAY = 0x0060, | | mwStatus_AWAY = 0x0060, | |
| mwStatus_BUSY = 0x0080 | | mwStatus_BUSY = 0x0080 | |
| }; | | }; | |
| | | | |
| /* 8.2.3 User Status Block */ | | /* 8.2.3 User Status Block */ | |
| | | | |
| struct mwUserStatus { | | struct mwUserStatus { | |
|
| enum mwStatusType status; /* status of user (see 8.3.5) */ | | enum mwStatusType status; /**< status of user (see 8.3.5) */ | |
| guint time; /* last status change time in seconds */ | | guint time; /**< last status change time in seconds */ | |
| gchar *desc; /* status description */ | | char *desc; /**< status description */ | |
| }; | | }; | |
| | | | |
|
| gsize mwUserStatus_buflen(struct mwUserStatus *stat); | | | |
| | | | |
| int mwUserStatus_put(gchar **b, gsize *n, struct mwUserStatus *stat); | | | |
| | | | |
| int mwUserStatus_get(gchar **b, gsize *n, struct mwUserStatus *stat); | | | |
| | | | |
| void mwUserStatus_clear(struct mwUserStatus *stat); | | | |
| | | | |
| void mwUserStatus_clone(struct mwUserStatus *to, struct mwUserStatus *from) | | | |
| ; | | | |
| | | | |
| /* 8.2.4 ID Block */ | | /* 8.2.4 ID Block */ | |
| | | | |
| struct mwIdBlock { | | struct mwIdBlock { | |
|
| gchar *user; /* user id (login id or empty for some services) */ | | char *user; /**< user id (login id or empty for some services) */ | |
| gchar *community; /* community name (empty for same community) */ | | char *community; /**< community name (empty for same community) */ | |
| }; | | }; | |
| | | | |
|
| gsize mwIdBlock_buflen(struct mwIdBlock *id); | | | |
| | | | |
| int mwIdBlock_put(gchar **b, gsize *n, struct mwIdBlock *id); | | | |
| | | | |
| int mwIdBlock_get(gchar **b, gsize *n, struct mwIdBlock *id); | | | |
| | | | |
| void mwIdBlock_clear(struct mwIdBlock *id); | | | |
| | | | |
| void mwIdBlock_clone(struct mwIdBlock *to, struct mwIdBlock *from); | | | |
| | | | |
| int mwIdBlock_equal(struct mwIdBlock *a, struct mwIdBlock *b); | | | |
| | | | |
| /* 8.2.5 Encryption Block */ | | /* 8.2.5 Encryption Block */ | |
| | | | |
| enum mwEncryptType { | | enum mwEncryptType { | |
| mwEncrypt_NONE = 0x0000, | | mwEncrypt_NONE = 0x0000, | |
| mwEncrypt_ANY = 0x0001, /* what's the difference between ANY */ | | mwEncrypt_ANY = 0x0001, /* what's the difference between ANY */ | |
| mwEncrypt_ALL = 0x0002, /* and ALL ? */ | | mwEncrypt_ALL = 0x0002, /* and ALL ? */ | |
| mwEncrypt_RC2_40 = 0x1000 | | mwEncrypt_RC2_40 = 0x1000 | |
| }; | | }; | |
| | | | |
| struct mwEncryptBlock { | | struct mwEncryptBlock { | |
| enum mwEncryptType type; | | enum mwEncryptType type; | |
| struct mwOpaque opaque; | | struct mwOpaque opaque; | |
| }; | | }; | |
| | | | |
|
| gsize mwEncryptBlock_buflen(struct mwEncryptBlock *eb); | | | |
| | | | |
| int mwEncryptBlock_put(gchar **b, gsize *n, struct mwEncryptBlock *eb); | | | |
| | | | |
| int mwEncryptBlock_get(gchar **b, gsize *n, struct mwEncryptBlock *eb); | | | |
| | | | |
| void mwEncryptBlock_clear(struct mwEncryptBlock *enc); | | | |
| | | | |
| void mwEncryptBlock_clone(struct mwEncryptBlock *to, | | | |
| struct mwEncryptBlock *from); | | | |
| | | | |
| /* 8.3.8.2 Awareness Presence Types */ | | /* 8.3.8.2 Awareness Presence Types */ | |
| | | | |
| enum mwAwareType { | | enum mwAwareType { | |
| mwAware_USER = 0x0002 | | mwAware_USER = 0x0002 | |
| }; | | }; | |
| | | | |
| /* 8.4.2 Awareness Messages */ | | /* 8.4.2 Awareness Messages */ | |
| /* 8.4.2.1 Awareness ID Block */ | | /* 8.4.2.1 Awareness ID Block */ | |
| | | | |
| struct mwAwareIdBlock { | | struct mwAwareIdBlock { | |
| enum mwAwareType type; | | enum mwAwareType type; | |
|
| gchar *user; | | char *user; | |
| gchar *community; | | char *community; | |
| }; | | }; | |
| | | | |
|
| gsize mwAwareIdBlock_buflen(struct mwAwareIdBlock *idb); | | | |
| | | | |
| int mwAwareIdBlock_put(gchar **b, gsize *n, struct mwAwareIdBlock *idb); | | | |
| | | | |
| int mwAwareIdBlock_get(gchar **b, gsize *n, struct mwAwareIdBlock *idb); | | | |
| | | | |
| void mwAwareIdBlock_clear(struct mwAwareIdBlock *idb); | | | |
| | | | |
| /* 8.4.2.4 Snapshot */ | | /* 8.4.2.4 Snapshot */ | |
| | | | |
| struct mwSnapshotAwareIdBlock { | | struct mwSnapshotAwareIdBlock { | |
| struct mwAwareIdBlock id; | | struct mwAwareIdBlock id; | |
| gboolean online; | | gboolean online; | |
|
| gchar *alt_id; | | char *alt_id; | |
| struct mwUserStatus status; | | struct mwUserStatus status; | |
|
| gchar *wtf; /* wtf is this? */ | | char *wtf; /* wtf is this? */ | |
| }; | | }; | |
| | | | |
|
| int mwSnapshotAwareIdBlock_get(gchar **b, gsize *n, | | | |
| struct mwSnapshotAwareIdBlock *idb); | | | |
| | | | |
| void mwSnapshotAwareIdBlock_clear(struct mwSnapshotAwareIdBlock *idb); | | | |
| | | | |
| /* 8.3.1.5 Resolve error codes */ | | /* 8.3.1.5 Resolve error codes */ | |
| | | | |
| enum mwResultCode { | | enum mwResultCode { | |
| mwResult_SUCCESS = 0x00000000, | | mwResult_SUCCESS = 0x00000000, | |
| mwResult_PARTIAL = 0x00010000, | | mwResult_PARTIAL = 0x00010000, | |
| mwResult_MULTIPLE = 0x80020000, | | mwResult_MULTIPLE = 0x80020000, | |
| mwResult_BAD_FORMAT = 0x80030000 | | mwResult_BAD_FORMAT = 0x80030000 | |
| }; | | }; | |
| | | | |
| /* 8.4.4.2 Resolve Response */ | | /* 8.4.4.2 Resolve Response */ | |
| | | | |
| struct mwResolveMatch { | | struct mwResolveMatch { | |
|
| gchar *id; | | char *id; | |
| gchar *name; | | char *name; | |
| gchar *desc; | | char *desc; | |
| }; | | }; | |
| | | | |
| struct mwResolveResult { | | struct mwResolveResult { | |
| enum mwResultCode code; | | enum mwResultCode code; | |
|
| gchar *name; | | char *name; | |
| guint count; | | guint count; | |
| struct mwResolveMatch *matches; | | struct mwResolveMatch *matches; | |
| }; | | }; | |
| | | | |
|
| | | /** @name Basic Data Type Marshalling | |
| | | The basic types are combined to construct the complex types. | |
| | | */ | |
| | | /*@{*/ | |
| | | | |
| | | int guint16_put(char **b, gsize *n, guint val); | |
| | | | |
| | | int guint16_get(char **b, gsize *n, guint *val); | |
| | | | |
| | | guint guint16_peek(const char *b, gsize n); | |
| | | | |
| | | int guint32_put(char **b, gsize *n, guint val); | |
| | | | |
| | | int guint32_get(char **b, gsize *n, guint *val); | |
| | | | |
| | | guint guint32_peek(const char *b, gsize n); | |
| | | | |
| | | int gboolean_put(char **b, gsize *n, gboolean val); | |
| | | | |
| | | int gboolean_get(char **b, gsize *n, gboolean *val); | |
| | | | |
| | | gboolean gboolean_peek(const char *b, gsize n); | |
| | | | |
| | | gsize mwString_buflen(const char *str); | |
| | | | |
| | | int mwString_put(char **b, gsize *n, const char *str); | |
| | | | |
| | | int mwString_get(char **b, gsize *n, char **str); | |
| | | | |
| | | gsize mwOpaque_buflen(struct mwOpaque *o); | |
| | | | |
| | | int mwOpaque_put(char **b, gsize *n, struct mwOpaque *o); | |
| | | | |
| | | int mwOpaque_get(char **b, gsize *n, struct mwOpaque *o); | |
| | | | |
| | | void mwOpaque_clear(struct mwOpaque *o); | |
| | | | |
| | | void mwOpaque_clone(struct mwOpaque *to, struct mwOpaque *from); | |
| | | | |
| | | /*@}*/ | |
| | | | |
| | | /** @name Complex Data Type Marshalling */ | |
| | | /*@{*/ | |
| | | | |
| | | gsize mwLoginInfo_buflen(struct mwLoginInfo *info); | |
| | | | |
| | | int mwLoginInfo_put(char **b, gsize *n, struct mwLoginInfo *info); | |
| | | | |
| | | int mwLoginInfo_get(char **b, gsize *n, struct mwLoginInfo *info); | |
| | | | |
| | | void mwLoginInfo_clear(struct mwLoginInfo *info); | |
| | | | |
| | | void mwLoginInfo_clone(struct mwLoginInfo *to, struct mwLoginInfo *from); | |
| | | | |
| | | gsize mwUserItem_buflen(struct mwUserItem *user); | |
| | | | |
| | | int mwUserItem_put(char **b, gsize *n, struct mwUserItem *user); | |
| | | | |
| | | int mwUserItem_get(char **b, gsize *n, struct mwUserItem *user); | |
| | | | |
| | | void mwUserItem_clear(struct mwUserItem *user); | |
| | | | |
| | | gsize mwPrivacyInfo_buflen(struct mwPrivacyInfo *info); | |
| | | | |
| | | int mwPrivacyInfo_put(char **b, gsize *n, struct mwPrivacyInfo *info); | |
| | | | |
| | | int mwPrivacyInfo_get(char **b, gsize *n, struct mwPrivacyInfo *info); | |
| | | | |
| | | void mwPrivacyInfo_clear(struct mwPrivacyInfo *info); | |
| | | | |
| | | gsize mwUserStatus_buflen(struct mwUserStatus *stat); | |
| | | | |
| | | int mwUserStatus_put(char **b, gsize *n, struct mwUserStatus *stat); | |
| | | | |
| | | int mwUserStatus_get(char **b, gsize *n, struct mwUserStatus *stat); | |
| | | | |
| | | void mwUserStatus_clear(struct mwUserStatus *stat); | |
| | | | |
| | | void mwUserStatus_clone(struct mwUserStatus *to, struct mwUserStatus *from) | |
| | | ; | |
| | | | |
| | | gsize mwIdBlock_buflen(struct mwIdBlock *id); | |
| | | | |
| | | int mwIdBlock_put(char **b, gsize *n, struct mwIdBlock *id); | |
| | | | |
| | | int mwIdBlock_get(char **b, gsize *n, struct mwIdBlock *id); | |
| | | | |
| | | void mwIdBlock_clear(struct mwIdBlock *id); | |
| | | | |
| | | void mwIdBlock_clone(struct mwIdBlock *to, struct mwIdBlock *from); | |
| | | | |
| | | gboolean mwIdBlock_equal(struct mwIdBlock *a, struct mwIdBlock *b); | |
| | | | |
| | | gsize mwEncryptBlock_buflen(struct mwEncryptBlock *eb); | |
| | | | |
| | | int mwEncryptBlock_put(char **b, gsize *n, struct mwEncryptBlock *eb); | |
| | | | |
| | | int mwEncryptBlock_get(char **b, gsize *n, struct mwEncryptBlock *eb); | |
| | | | |
| | | void mwEncryptBlock_clear(struct mwEncryptBlock *enc); | |
| | | | |
| | | void mwEncryptBlock_clone(struct mwEncryptBlock *to, | |
| | | struct mwEncryptBlock *from); | |
| | | | |
| | | gsize mwAwareIdBlock_buflen(struct mwAwareIdBlock *idb); | |
| | | | |
| | | int mwAwareIdBlock_put(char **b, gsize *n, struct mwAwareIdBlock *idb); | |
| | | | |
| | | int mwAwareIdBlock_get(char **b, gsize *n, struct mwAwareIdBlock *idb); | |
| | | | |
| | | void mwAwareIdBlock_clear(struct mwAwareIdBlock *idb); | |
| | | | |
| | | void mwAwareIdBlock_clone(struct mwAwareIdBlock *to, | |
| | | struct mwAwareIdBlock *from); | |
| | | | |
| | | gboolean mwAwareIdBlock_equal(struct mwAwareIdBlock *a, | |
| | | struct mwAwareIdBlock *b); | |
| | | | |
| | | int mwSnapshotAwareIdBlock_get(char **b, gsize *n, | |
| | | struct mwSnapshotAwareIdBlock *idb); | |
| | | | |
| | | void mwSnapshotAwareIdBlock_clear(struct mwSnapshotAwareIdBlock *idb); | |
| | | | |
| | | void mwSnapshotAwareIdBlock_clone(struct mwSnapshotAwareIdBlock *to, | |
| | | struct mwSnapshotAwareIdBlock *from); | |
| | | | |
| | | /*@}*/ | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 31 change blocks. |
| 134 lines changed or deleted | | 194 lines changed or added | |
|
| error.h | | error.h | |
| | | | |
| #ifndef _MW_ERROR_ | | #ifndef _MW_ERROR_ | |
| #define _MW_ERROR_ | | #define _MW_ERROR_ | |
| | | | |
|
| char* mwError(unsigned int code); | | #include <glib.h> | |
| | | | |
| | | char* mwError(guint32 code); | |
| | | | |
| /* 8.3 Constants */ | | /* 8.3 Constants */ | |
| /* 8.3.1 Error Codes */ | | /* 8.3.1 Error Codes */ | |
| /* 8.3.1.1 General error/success codes */ | | /* 8.3.1.1 General error/success codes */ | |
| | | | |
| enum ERR_GENERAL { | | enum ERR_GENERAL { | |
| ERR_SUCCESS = 0x00000000, | | ERR_SUCCESS = 0x00000000, | |
| ERR_FAILURE = 0x80000000, | | ERR_FAILURE = 0x80000000, | |
| ERR_REQUEST_DELAY = 0x00000001, | | ERR_REQUEST_DELAY = 0x00000001, | |
| ERR_REQUEST_INVALID = 0x80000001, | | ERR_REQUEST_INVALID = 0x80000001, | |
| | | | |
| skipping to change at line 75 | | skipping to change at line 77 | |
| #define SERVER_NORESPOND 0x8000020C | | #define SERVER_NORESPOND 0x8000020C | |
| #define CANT_CONNECT 0x8000020D | | #define CANT_CONNECT 0x8000020D | |
| #define USER_REMOVED 0x8000020E | | #define USER_REMOVED 0x8000020E | |
| #define PROTOCOL_ERROR 0x8000020F | | #define PROTOCOL_ERROR 0x8000020F | |
| #define USER_RESTRICTED 0x80000210 | | #define USER_RESTRICTED 0x80000210 | |
| #define INCORRECT_LOGIN 0x80000211 | | #define INCORRECT_LOGIN 0x80000211 | |
| #define ENCRYPT_MISMATCH 0x80000212 | | #define ENCRYPT_MISMATCH 0x80000212 | |
| #define USER_UNREGISTERED 0x80000213 | | #define USER_UNREGISTERED 0x80000213 | |
| #define VERIFICATION_DOWN 0x80000214 | | #define VERIFICATION_DOWN 0x80000214 | |
| #define USER_TOO_IDLE 0x80000216 | | #define USER_TOO_IDLE 0x80000216 | |
|
| #define GUES_IN_USE 0x80000217 | | #define GUEST_IN_USE 0x80000217 | |
| #define USER_EXISTS 0x80000218 | | #define USER_EXISTS 0x80000218 | |
| #define USER_RE_LOGIN 0x80000219 | | #define USER_RE_LOGIN 0x80000219 | |
| #define BAD_NAME 0x8000021A | | #define BAD_NAME 0x8000021A | |
| #define REG_MODE_NS 0x8000021B | | #define REG_MODE_NS 0x8000021B | |
| #define WRONG_USER_PRIV 0x8000021C | | #define WRONG_USER_PRIV 0x8000021C | |
| #define NEED_EMAIL 0x8000021D | | #define NEED_EMAIL 0x8000021D | |
| #define DNS_ERROR 0x8000021E | | #define DNS_ERROR 0x8000021E | |
| #define DNS_FATAL_ERROR 0x8000021F | | #define DNS_FATAL_ERROR 0x8000021F | |
| #define DNS_NOT_FOUND 0x80000220 | | #define DNS_NOT_FOUND 0x80000220 | |
| #define CONNECTION_BROKEN 0x80000221 | | #define CONNECTION_BROKEN 0x80000221 | |
| #define CONNECTION_ABORTED 0x80000222 | | #define CONNECTION_ABORTED 0x80000222 | |
| #define CONNECTION_REFUSED 0x80000223 | | #define CONNECTION_REFUSED 0x80000223 | |
| #define CONNECTION_RESET 0x80000224 | | #define CONNECTION_RESET 0x80000224 | |
| #define CONNECTION_TIMED 0x80000225 | | #define CONNECTION_TIMED 0x80000225 | |
| #define CONNECTION_CLOSED 0x80000226 | | #define CONNECTION_CLOSED 0x80000226 | |
| #define MULTI_SERVER_LOGIN 0x80000227 | | #define MULTI_SERVER_LOGIN 0x80000227 | |
|
| #define MULTI_SERVER_LOGIN2 0x80000228 | | #define MULTI_SERVER_LOGIN2 0x80000228 /* maps to 0x80000227 for compat */ | |
| #define MULTI_LOGIN_COMP 0x80000229 | | #define MULTI_LOGIN_COMP 0x80000229 | |
| #define MUTLI_LOGIN_ALREADY 0x8000022A | | #define MUTLI_LOGIN_ALREADY 0x8000022A | |
| #define SERVER_BROKEN 0x8000022B | | #define SERVER_BROKEN 0x8000022B | |
| #define SERVER_PATH_OLD 0x8000022C | | #define SERVER_PATH_OLD 0x8000022C | |
| #define APPLET_LOGOUT 0x8000022D /* what??? */ | | #define APPLET_LOGOUT 0x8000022D /* what??? */ | |
| | | | |
| /* 8.3.1.3 Client error codes */ | | /* 8.3.1.3 Client error codes */ | |
| | | | |
| enum ERR_CLIENT { | | enum ERR_CLIENT { | |
| ERR_CLIENT_USER_GONE = 0x80002000, /* user isn't here */ | | ERR_CLIENT_USER_GONE = 0x80002000, /* user isn't here */ | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 5 lines changed or added | |
|
| message.h | | message.h | |
| | | | |
| #ifndef _MW_MESSAGE_ | | #ifndef _MW_MESSAGE_ | |
| #define _MW_MESSAGE_ | | #define _MW_MESSAGE_ | |
| | | | |
| #include "common.h" | | #include "common.h" | |
| | | | |
|
| #define MESSAGE(msg) (&msg->head) | | /** Cast a pointer to a message subtype (eg, mwMsgHandshake, | |
| | | mwMsgAdmin) into a pointer to a mwMessage */ | |
| | | #define MW_MESSAGE(msg) (&msg->head) | |
| | | | |
|
| | | /** Indicates the type of a message. */ | |
| enum mwMessageType { | | enum mwMessageType { | |
|
| mwMessage_HANDSHAKE = 0x0000, | | mwMessage_HANDSHAKE = 0x0000, /**< mwMsgHandshake */ | |
| mwMessage_HANDSHAKE_ACK = 0x8000, | | mwMessage_HANDSHAKE_ACK = 0x8000, /**< mwMsgHandshakeAck */ | |
| mwMessage_LOGIN = 0x0001, | | mwMessage_LOGIN = 0x0001, /**< mwMsgLogin */ | |
| /* mwMessage_LOGIN_REDIRECT = ..., | | /* mwMessage_LOGIN_REDIRECT = ..., | |
| mwMessage_LOGIN_CONTINUE = ..., */ | | mwMessage_LOGIN_CONTINUE = ..., */ | |
|
| mwMessage_LOGIN_ACK = 0x8001, | | mwMessage_LOGIN_ACK = 0x8001, /**< mwMsgLoginAck */ | |
| mwMessage_CHANNEL_CREATE = 0x0002, | | mwMessage_CHANNEL_CREATE = 0x0002, /**< mwMsgChannelCreate */ | |
| mwMessage_CHANNEL_DESTROY = 0x0003, | | mwMessage_CHANNEL_DESTROY = 0x0003, /**< mwMsgChannelDestroy */ | |
| mwMessage_CHANNEL_SEND = 0x0004, | | mwMessage_CHANNEL_SEND = 0x0004, /**< mwMsgChannelSend */ | |
| mwMessage_CHANNEL_ACCEPT = 0x0006, | | mwMessage_CHANNEL_ACCEPT = 0x0006, /**< mwMsgChannelAccept */ | |
| mwMessage_SET_USER_STATUS = 0x0009, | | mwMessage_SET_USER_STATUS = 0x0009, /**< mwMsgSetUserStatus */ | |
| mwMessage_SET_PRIVACY_LIST = 0x0010, /* maybe? */ | | mwMessage_SET_PRIVACY_LIST = 0x0010, /**< mwMsgSetPrivacyList (maybe?) * | |
| mwMessage_SENSE_SERVICE = 0x0011, | | / | |
| mwMessage_ADMIN = 0x0019 | | mwMessage_SENSE_SERVICE = 0x0011, /**< mwMsgSenseService */ | |
| | | mwMessage_ADMIN = 0x0019 /**< mwMsgAdmin */ | |
| }; | | }; | |
| | | | |
| enum mwMessageOption { | | enum mwMessageOption { | |
| mwMessageOption_NONE = 0x0000, | | mwMessageOption_NONE = 0x0000, | |
| mwMessageOption_HAS_ATTRIBS = 0x8000, | | mwMessageOption_HAS_ATTRIBS = 0x8000, | |
| mwMessageOption_ENCRYPT = 0x4000 | | mwMessageOption_ENCRYPT = 0x4000 | |
| }; | | }; | |
| | | | |
| struct mwMessage { | | struct mwMessage { | |
| enum mwMessageType type; | | enum mwMessageType type; | |
| enum mwMessageOption options; | | enum mwMessageOption options; | |
|
| unsigned int channel; | | guint channel; | |
| struct mwOpaque attribs; | | struct mwOpaque attribs; | |
| }; | | }; | |
| | | | |
|
| | | /** Allocate and initialize a new message of the specified type */ | |
| struct mwMessage *mwMessage_new(enum mwMessageType type); | | struct mwMessage *mwMessage_new(enum mwMessageType type); | |
| | | | |
|
| /* build a message from its representation. buf should already have been | | /** build a message from its representation. buf should already have | |
| advanced past the four-byte length indicator */ | | been advanced past the four-byte length indicator */ | |
| struct mwMessage *mwMessage_get(const char *buf, unsigned int len); | | struct mwMessage *mwMessage_get(const char *buf, gsize len); | |
| | | | |
|
| unsigned int mwMessage_buflen(struct mwMessage *msg); | | gsize mwMessage_buflen(struct mwMessage *msg); | |
| | | | |
|
| int mwMessage_put(char **buf, unsigned int *len, struct mwMessage *msg); | | int mwMessage_put(char **b, gsize *n, struct mwMessage *msg); | |
| | | | |
| void mwMessage_free(struct mwMessage *msg); | | void mwMessage_free(struct mwMessage *msg); | |
| | | | |
| /* 8.4 Messages */ | | /* 8.4 Messages */ | |
| /* 8.4.1 Basic Community Messages */ | | /* 8.4.1 Basic Community Messages */ | |
| /* 8.4.1.1 Handshake */ | | /* 8.4.1.1 Handshake */ | |
| | | | |
| struct mwMsgHandshake { | | struct mwMsgHandshake { | |
| struct mwMessage head; | | struct mwMessage head; | |
| unsigned int major; | | unsigned int major; | |
| | | | |
| skipping to change at line 142 | | skipping to change at line 146 | |
| unsigned int proto_type; | | unsigned int proto_type; | |
| unsigned int proto_ver; | | unsigned int proto_ver; | |
| struct mwOpaque addtl; | | struct mwOpaque addtl; | |
| gboolean acceptor_flag; | | gboolean acceptor_flag; | |
| struct mwLoginInfo acceptor; | | struct mwLoginInfo acceptor; | |
| struct mwEncryptBlock encrypt; | | struct mwEncryptBlock encrypt; | |
| }; | | }; | |
| | | | |
| /* 8.4.1.9 SendOnCnl */ | | /* 8.4.1.9 SendOnCnl */ | |
| | | | |
|
| enum mwChannelSendType { | | | |
| mwChannelSend_CONF_WELCOME = 0x0000, /* grr. shouldn't use zero */ | | | |
| mwChannelSend_CONF_INVITE = 0x0001, | | | |
| mwChannelSend_CONF_JOIN = 0x0002, | | | |
| mwChannelSend_CONF_PART = 0x0003, | | | |
| mwChannelSend_CONF_MESSAGE = 0x0004, /* conference */ | | | |
| mwChannelSend_CHAT_MESSAGE = 0x0064, /* im */ | | | |
| mwChannelSend_AWARE_ADD = 0x0068, | | | |
| mwChannelSend_AWARE_REMOVE = 0x0069, | | | |
| mwChannelSend_AWARE_SNAPSHOT = 0x01f4, | | | |
| mwChannelSend_AWARE_UPDATE = 0x01f5, | | | |
| mwChannelSend_RESOLVE_SEARCH = 0x8000, /* placeholder */ | | | |
| mwChannelSend_RESOLVE_RESULT = 0x8001 /* placeholder */ | | | |
| }; | | | |
| | | | |
| struct mwMsgChannelSend { | | struct mwMsgChannelSend { | |
| struct mwMessage head; | | struct mwMessage head; | |
|
| enum mwChannelSendType type; | | | |
| | | /** each service defines its own send types. The uniqueness of a | |
| | | type is only necessary within a given service */ | |
| | | guint type; | |
| | | | |
| | | /** protocol data to be interpreted by the handling service */ | |
| struct mwOpaque data; | | struct mwOpaque data; | |
| }; | | }; | |
| | | | |
| /* 8.4.1.10 DestroyCnl */ | | /* 8.4.1.10 DestroyCnl */ | |
| | | | |
| struct mwMsgChannelDestroy { | | struct mwMsgChannelDestroy { | |
| struct mwMessage head; | | struct mwMessage head; | |
| guint reason; | | guint reason; | |
| struct mwOpaque data; | | struct mwOpaque data; | |
| }; | | }; | |
| | | | |
End of changes. 11 change blocks. |
| 35 lines changed or deleted | | 30 lines changed or added | |
|
| service.h | | service.h | |
| | | | |
| skipping to change at line 13 | | skipping to change at line 13 | |
| #define _MW_SERVICE_H | | #define _MW_SERVICE_H | |
| | | | |
| #include <glib.h> | | #include <glib.h> | |
| | | | |
| struct mwChannel; | | struct mwChannel; | |
| struct mwSession; | | struct mwSession; | |
| struct mwMsgChannelCreate; | | struct mwMsgChannelCreate; | |
| struct mwMsgChannelAccept; | | struct mwMsgChannelAccept; | |
| struct mwMsgChannelDestroy; | | struct mwMsgChannelDestroy; | |
| | | | |
|
| enum BaseServiceTypes { | | /** Identification numbers for the basic services | |
| Service_AWARE = 0x00000011, /* buddy list */ | | @relates mwService::type */ | |
| Service_RESOLVE = 0x00000015, /* name resolution */ | | enum mwBaseServiceTypes { | |
| Service_IM = 0x00001000, /* instant messaging */ | | mwService_AWARE = 0x00000011, /**< buddy list */ | |
| Service_CONF = 0x80000010, /* conferencing */ | | mwService_RESOLVE = 0x00000015, /**< name resolution */ | |
| | | mwService_STORAGE = 0x00000018, /**< storage */ | |
| | | mwService_IM = 0x00001000, /**< instant messaging */ | |
| | | mwService_CONF = 0x80000010, /**< conferencing */ | |
| }; | | }; | |
| | | | |
|
| enum BaseProtocolTypes { | | /** Identification numbers for the basic service protocols */ | |
| Protocol_AWARE = 0x00000011, | | enum mwBaseProtocolTypes { | |
| Protocol_RESOLVE = 0x00000015, | | mwProtocol_AWARE = 0x00000011, | |
| Protocol_IM = 0x00001000, | | mwProtocol_RESOLVE = 0x00000015, | |
| Protocol_CONF = 0x00000010 | | mwProtocol_STORAGE = 0x00000025, | |
| | | mwProtocol_IM = 0x00001000, | |
| | | mwProtocol_CONF = 0x00000010 | |
| }; | | }; | |
| | | | |
|
| /* A service is the recipient of sendOnCnl messages sent over channels | | /** State-tracking for a service */ | |
| marked with the corresponding service id. Services provide | | enum mwServiceState { | |
| functionality such as IM relaying, Awareness tracking and | | mwServiceState_STOPPED, /**< the service is not active */ | |
| notification, and Conference handling. It is a services | | mwServiceState_STOPPING, /**< the service is shutting down */ | |
| responsibility to accept or destroy channels, and to process data | | mwServiceState_STARTED, /**< the service is active */ | |
| sent over those channels */ | | mwServiceState_STARTING /**< the service is starting up */ | |
| | | }; | |
| | | | |
| | | /** Casts a concrete service (such as mwServiceAware) into a mwService */ | |
| | | #define MW_SERVICE(srv) ((struct mwService *) srv) | |
| | | | |
| | | #define MW_SERVICE_IS_STOPPED(srvc) \ | |
| | | (mwService_getState(MW_SERVICE(srvc)) == mwServiceState_STOPPED) | |
| | | | |
| | | #define MW_SERVICE_IS_STOPPING(srvc) \ | |
| | | (mwService_getState(MW_SERVICE(srvc)) == mwServiceState_STOPPING) | |
| | | | |
| | | #define MW_SERVICE_IS_STARTED(srvc) \ | |
| | | (mwService_getState(MW_SERVICE(srvc)) == mwServiceState_STARTED) | |
| | | | |
| | | #define MW_SERVICE_IS_STARTING(srvc) \ | |
| | | (mwService_getState(MW_SERVICE(srvc)) == mwServiceState_STARTING) | |
| | | | |
| | | /** If a service is STARTING or STARTED, it's LIVE */ | |
| | | #define MW_SERVICE_IS_LIVE(srvc) \ | |
| | | (MW_SERVICE_IS_STARTING(srvc) || MW_SERVICE_IS_STARTED(srvc)) | |
| | | | |
| | | /** If a service is STOPPING or STOPPED, it's DEAD */ | |
| | | #define MW_SERVICE_IS_DEAD(srvc) \ | |
| | | (MW_SERVICE_IS_STOPPING(srvc) || MW_SERVICE_IS_STOPPED(srvc)) | |
| | | | |
| | | /** A service is the recipient of sendOnCnl messages sent over | |
| | | channels marked with the corresponding service id. Services | |
| | | provide functionality such as IM relaying, Awareness tracking and | |
| | | notification, and Conference handling. It is a service's | |
| | | responsibility to accept or destroy channels, and to process data | |
| | | sent over those channels */ | |
| struct mwService { | | struct mwService { | |
| | | | |
|
| /* the unique key by which this service is registered. */ | | /** the unique identifier by which this service is registered. | |
| | | @relates BaseServiceTypes */ | |
| guint32 type; | | guint32 type; | |
| | | | |
|
| /* session this service is attached to */ | | /** the state of this service. Determines whether or not the session | |
| | | should call the start function upon receipt of a service | |
| | | available message. Should not be set or checked by hand. | |
| | | @relates mwService_getState */ | |
| | | enum mwServiceState state; | |
| | | | |
| | | /** session this service is attached to. | |
| | | @relates mwService_getSession */ | |
| struct mwSession *session; | | struct mwSession *session; | |
| | | | |
|
| | | /** @return string short name of the service | |
| | | @relates mwService_getName */ | |
| const char *(*get_name)(); | | const char *(*get_name)(); | |
|
| | | | |
| | | /** @return string short description of the service | |
| | | @relates mwService_getDesc */ | |
| const char *(*get_desc)(); | | const char *(*get_desc)(); | |
| | | | |
|
| | | /** The service's channel create handler. Called when the session | |
| | | receives a channel create message with a service matching this | |
| | | service's type. | |
| | | @relates mwService_recvChannelCreate */ | |
| void (*recv_channelCreate)(struct mwService *, struct mwChannel *, | | void (*recv_channelCreate)(struct mwService *, struct mwChannel *, | |
| struct mwMsgChannelCreate *); | | struct mwMsgChannelCreate *); | |
| | | | |
|
| | | /** The service's channel accept handler. Called when the session | |
| | | receives a channel accept message for a channel with a service | |
| | | matching this service's type. | |
| | | @relates mwService_recvChannelAccept */ | |
| void (*recv_channelAccept)(struct mwService *, struct mwChannel *, | | void (*recv_channelAccept)(struct mwService *, struct mwChannel *, | |
| struct mwMsgChannelAccept *); | | struct mwMsgChannelAccept *); | |
| | | | |
|
| | | /** The service's channel destroy handler. Called when the session | |
| | | receives a channel destroy message for a channel with a service | |
| | | matching this service's type. | |
| | | @relates mwService_recvChannelDestroy */ | |
| void (*recv_channelDestroy)(struct mwService *, struct mwChannel *, | | void (*recv_channelDestroy)(struct mwService *, struct mwChannel *, | |
| struct mwMsgChannelDestroy *); | | struct mwMsgChannelDestroy *); | |
| | | | |
|
| void (*recv)(struct mwService *, struct mwChannel *, guint32 msg_type, | | /** The service's input handler. Called when the session receives | |
| | | data on a channel with a service matching this service's | |
| | | type. | |
| | | @relates mwService_recv */ | |
| | | void (*recv)(struct mwService *, struct mwChannel *, guint16 msg_type, | |
| const char *, gsize); | | const char *, gsize); | |
| | | | |
|
| | | /** The service's start handler. Called upon the receipt of a | |
| | | service available message. | |
| | | @relates mwService_start */ | |
| | | void (*start)(struct mwService *); | |
| | | | |
| | | /** The service's stop handler. Called when the session is shutting | |
| | | down, or when the service is free'd. | |
| | | @relates mwService_stop */ | |
| | | void (*stop)(struct mwService *); | |
| | | | |
| | | /** The service's cleanup handler. | |
| | | @relates mwService_free */ | |
| void (*clear)(struct mwService *); | | void (*clear)(struct mwService *); | |
| }; | | }; | |
| | | | |
|
| void mwService_recvChannelCreate(struct mwService *, struct mwChannel *, | | /** Prepares a newly allocated service for use. Connects the base | |
| struct mwMsgChannelCreate *); | | service signals, etc. | |
| | | | |
|
| void mwService_recvChannelAccept(struct mwService *, struct mwChannel *, | | Intended for use by service implementations, rather than by code | |
| struct mwMsgChannelAccept *); | | utilizing a service. | |
| | | | |
|
| void mwService_recvChannelDestroy(struct mwService *, struct mwChannel *, | | The service state will be initialized to STOPPED. | |
| struct mwMsgChannelDestroy *); | | | |
| | | | |
|
| void mwService_recv(struct mwService *, struct mwChannel *, guint32 msg_typ | | @param service The service to initialize | |
| e, | | @param session The service's owning session | |
| const char *, gsize); | | @param service_type The service number | |
| | | */ | |
| | | void mwService_init(struct mwService *service, struct mwSession *session, | |
| | | guint32 service_type); | |
| | | | |
| | | /** @name General Services API | |
| | | | |
| | | These functions provide unified access to the general functions of | |
| | | a client service, with some simple sanity-checking. */ | |
| | | /*@{*/ | |
| | | | |
|
| | | /** Triggers the recv_channelCreate handler on the service. | |
| | | @param service the service to handle the message | |
| | | @param channel the channel being created | |
| | | @param msg the channel create message | |
| | | */ | |
| | | void mwService_recvChannelCreate(struct mwService *service, | |
| | | struct mwChannel *channel, | |
| | | struct mwMsgChannelCreate *msg); | |
| | | | |
| | | /** Triggers the recv_channelAccept handler on the service. | |
| | | @param service the service to handle the message | |
| | | @param channel the channel being accepted | |
| | | @param msg the channel accept message | |
| | | */ | |
| | | void mwService_recvChannelAccept(struct mwService *service, | |
| | | struct mwChannel *channel, | |
| | | struct mwMsgChannelAccept *msg); | |
| | | | |
| | | /** Triggers the recv_channelDestroy handler on the service. | |
| | | @param service the service to handle the message | |
| | | @param channel the channel being destroyed | |
| | | @param msg the channel destroy message | |
| | | */ | |
| | | void mwService_recvChannelDestroy(struct mwService *service, | |
| | | struct mwChannel *channel, | |
| | | struct mwMsgChannelDestroy *msg); | |
| | | | |
| | | /** Triggers the input handler on the service | |
| | | @param service the service to receive the input | |
| | | @param channel the channel the input was received from | |
| | | @param msg_type the service-dependant message type | |
| | | @param buf the input buffer | |
| | | @param len the length of the input buffer | |
| | | */ | |
| | | void mwService_recv(struct mwService *service, struct mwChannel *channel, | |
| | | guint16 msg_type, const char *buf, gsize len); | |
| | | | |
| | | /** @return the appropriate type id for the service */ | |
| | | guint32 mwService_getServiceType(struct mwService *); | |
| | | | |
| | | /** @return string short name of the service */ | |
| const char *mwService_getName(struct mwService *); | | const char *mwService_getName(struct mwService *); | |
|
| | | | |
| | | /** @return string short description of the service */ | |
| const char *mwService_getDesc(struct mwService *); | | const char *mwService_getDesc(struct mwService *); | |
| | | | |
|
| struct mwSession *mwService_getSession(struct mwService *); | | /** @return the service's session */ | |
| void mwService_setSession(struct mwService *, struct mwSession *); | | struct mwSession *mwService_getSession(struct mwService *service); | |
| | | | |
|
| /* call the clean function, clean the service, free it, set it to | | /** @returns the service's state | |
| NULL */ | | @see MW_SERVICE_IS_STARTING | |
| void mwService_free(struct mwService **); | | @see MW_SERVICE_IS_STARTED | |
| | | @see MW_SERVICE_IS_STOPPING | |
| | | @see MW_SERVICE_IS_STOPPED | |
| | | @see MW_SERVICE_IS_LIVE | |
| | | @see MW_SERVICE_IS_DEAD | |
| | | */ | |
| | | enum mwServiceState mwService_getState(struct mwService *service); | |
| | | | |
| | | /** Triggers the start handler for the service. Normally called from | |
| | | the session upon receipt of a service available message. Service | |
| | | implementations should use this handler to open any necessary | |
| | | channels, etc. Checks that the service is STOPPED, or returns. | |
| | | | |
| | | @param service The service to start | |
| | | */ | |
| | | void mwService_start(struct mwService *service); | |
| | | | |
| | | /** Indicate that a service is started. To be used by service | |
| | | implementations when the service is fully started. */ | |
| | | void mwService_started(struct mwService *service); | |
| | | | |
| | | /** Triggers the stop handler for the service. Normally called from | |
| | | the session before closing down the connection. Checks that the | |
| | | service is STARTED or STARTING, or returns | |
| | | | |
| | | @param service The service to stop | |
| | | */ | |
| | | void mwService_stop(struct mwService *service); | |
| | | | |
| | | /** Indicate that a service is stopped. To be used by service | |
| | | implementations when the service is fully stopped. */ | |
| | | void mwService_stopped(struct mwService *service); | |
| | | | |
| | | /** Frees memory used by a service. Will trigger the stop handler if | |
| | | the service is STARTED or STARTING. Triggers clear handler to allow | |
| | | cleanup. | |
| | | | |
| | | @param service The service to clear and free | |
| | | */ | |
| | | void mwService_free(struct mwService *service); | |
| | | | |
| | | /*@}*/ | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 20 change blocks. |
| 33 lines changed or deleted | | 202 lines changed or added | |
|
| session.h | | session.h | |
| | | | |
| skipping to change at line 14 | | skipping to change at line 14 | |
| | | | |
| #include <glib.h> | | #include <glib.h> | |
| #include <glib/glist.h> | | #include <glib/glist.h> | |
| #include "common.h" | | #include "common.h" | |
| | | | |
| /* protocol versioning */ | | /* protocol versioning */ | |
| #ifndef PROTOCOL_VERSION_MAJOR | | #ifndef PROTOCOL_VERSION_MAJOR | |
| #define PROTOCOL_VERSION_MAJOR 0x001e | | #define PROTOCOL_VERSION_MAJOR 0x001e | |
| #endif | | #endif | |
| #ifndef PROTOCOL_VERSION_MINOR | | #ifndef PROTOCOL_VERSION_MINOR | |
|
| #define PROTOCOL_VERSION_MINOR 0x0017 | | #define PROTOCOL_VERSION_MINOR 0x001d | |
| #endif | | #endif | |
| | | | |
|
| /* how a session manages to feed data back to the server. */ | | /** how a session manages to perform output */ | |
| struct mwSessionHandler { | | struct mwSessionHandler { | |
| int (*write)(struct mwSessionHandler *, const char *, gsize); | | int (*write)(struct mwSessionHandler *, const char *, gsize); | |
| void (*close)(struct mwSessionHandler *); | | void (*close)(struct mwSessionHandler *); | |
| }; | | }; | |
| | | | |
| struct mwChannelSet; | | struct mwChannelSet; | |
| struct mwService; | | struct mwService; | |
| struct mwMessage; | | struct mwMessage; | |
| struct mwMsgHandshake; | | struct mwMsgHandshake; | |
| struct mwMsgHandshakeAck; | | struct mwMsgHandshakeAck; | |
| struct mwMsgLogin; | | struct mwMsgLogin; | |
| struct mwMsgLoginAck; | | struct mwMsgLoginAck; | |
| struct mwMsgLoginRedirect; | | struct mwMsgLoginRedirect; | |
| struct mwMsgLoginContinue; | | struct mwMsgLoginContinue; | |
| struct mwMsgSetPrivacyInfo; | | struct mwMsgSetPrivacyInfo; | |
| struct mwMsgSetUserStatus; | | struct mwMsgSetUserStatus; | |
| struct mwMsgAdmin; | | struct mwMsgAdmin; | |
| | | | |
| struct mwSession { | | struct mwSession { | |
| | | | |
|
| /* provides I/O capabilities for the session */ | | /** provides I/O capabilities for the session */ | |
| struct mwSessionHandler *handler; | | struct mwSessionHandler *handler; | |
| | | | |
|
| /* buffer for incoming message data */ | | char *buf; /**< buffer for incoming message data */ | |
| char *buf; | | gsize buf_len; /**< length of buf */ | |
| gsize buf_len; | | gsize buf_used; /**< offset to last-used byte of buf */ | |
| gsize buf_used; | | | |
| | | | |
|
| /* authentication data (usually password) */ | | /** authentication data (usually password) | |
| | | | |
| | | @todo the token auth_type is probably more ornate than just a | |
| | | string */ | |
| enum mwAuthType auth_type; | | enum mwAuthType auth_type; | |
| union { | | union { | |
| char *password; | | char *password; | |
| char *token; | | char *token; | |
| } auth; | | } auth; | |
| | | | |
|
| /* bits of user information. Obtained from server responses */ | | struct mwLoginInfo login; /**< login information for this session */ | |
| struct mwLoginInfo login; | | struct mwUserStatus status; /**< session's user status */ | |
| struct mwUserStatus status; | | struct mwPrivacyInfo privacy; /**< session's privacy list */ | |
| struct mwPrivacyInfo privacy; | | | |
| | | | |
|
| /* session key */ | | /** the session key | |
| | | | |
| | | @todo with new ciphers, this may need to become an EncryptBlock | |
| | | or something crazy */ | |
| int session_key[64]; | | int session_key[64]; | |
| | | | |
|
| /* the collection of channels */ | | /** the collection of channels */ | |
| struct mwChannelSet *channels; | | struct mwChannelSet *channels; | |
| | | | |
|
| /* collection of services */ | | /** the collection of services */ | |
| GList *services; | | GList *services; | |
| | | | |
| /* session call-backs */ | | /* session call-backs */ | |
|
| void (*on_initConnect)(struct mwSession *); | | void (*on_start)(struct mwSession *); | |
| void (*on_closeConnect)(struct mwSession *, guint32); | | void (*on_stop)(struct mwSession *, guint32); | |
| | | | |
| /* channel call-backs */ | | /* channel call-backs */ | |
| void (*on_channelOpen)(struct mwChannel *); | | void (*on_channelOpen)(struct mwChannel *); | |
| void (*on_channelClose)(struct mwChannel *); | | void (*on_channelClose)(struct mwChannel *); | |
| | | | |
| /* authentication call-backs */ | | /* authentication call-backs */ | |
| void (*on_handshake)(struct mwSession *, struct mwMsgHandshake *); | | void (*on_handshake)(struct mwSession *, struct mwMsgHandshake *); | |
| void (*on_handshakeAck)(struct mwSession *, struct mwMsgHandshakeAck *); | | void (*on_handshakeAck)(struct mwSession *, struct mwMsgHandshakeAck *); | |
| void (*on_login)(struct mwSession *, struct mwMsgLogin *); | | void (*on_login)(struct mwSession *, struct mwMsgLogin *); | |
| void (*on_loginRedirect)(struct mwSession *, struct mwMsgLoginRedirect *)
; | | void (*on_loginRedirect)(struct mwSession *, struct mwMsgLoginRedirect *)
; | |
| | | | |
| skipping to change at line 92 | | skipping to change at line 96 | |
| | | | |
| /* other call-backs */ | | /* other call-backs */ | |
| void (*on_setPrivacyInfo)(struct mwSession *, struct mwMsgSetPrivacyInfo
*); | | void (*on_setPrivacyInfo)(struct mwSession *, struct mwMsgSetPrivacyInfo
*); | |
| void (*on_setUserStatus)(struct mwSession *, struct mwMsgSetUserStatus *)
; | | void (*on_setUserStatus)(struct mwSession *, struct mwMsgSetUserStatus *)
; | |
| void (*on_admin)(struct mwSession *, struct mwMsgAdmin *); | | void (*on_admin)(struct mwSession *, struct mwMsgAdmin *); | |
| }; | | }; | |
| | | | |
| /* allocate and prepare a new session */ | | /* allocate and prepare a new session */ | |
| struct mwSession *mwSession_new(); | | struct mwSession *mwSession_new(); | |
| | | | |
|
| /* clear, free and NULL a session */ | | /* stop, clear, free a session. Does not free the contained services. */ | |
| void mwSession_free(struct mwSession **); | | void mwSession_free(struct mwSession *); | |
| | | | |
|
| /* instruct the session to begin. This will trigger the on_initConnect | | /** instruct the session to begin. This will trigger the on_start | |
| call-back. If there's no such call-back, this function does very | | call-back. If there's no such call-back, this function does very | |
| little. Use or wrap initConnect_sendHandshake as a call-back to | | little. Use or wrap onStart_sendHandshake as a call-back to have a | |
| have a handshake message sent, and to begin an actual session with | | handshake message sent, and to begin an actual session with a | |
| a sametime server */ | | sametime server */ | |
| void mwSession_initConnect(struct mwSession *); | | void mwSession_start(struct mwSession *); | |
| | | | |
|
| /* instruct the session to shut down with the following reason | | /** instruct the session to shut down with the following reason | |
| code. Triggers the on_closeConnect call-back */ | | code. Triggers the on_stop call-back */ | |
| void mwSession_closeConnect(struct mwSession *, guint32 reason); | | void mwSession_stop(struct mwSession *, guint32 reason); | |
| | | | |
|
| /* data is buffered, unpacked, and parsed into a message, then | | /** Data is buffered, unpacked, and parsed into a message, then | |
| processed accordingly. */ | | processed accordingly. */ | |
| void mwSession_recv(struct mwSession *, const char *, gsize); | | void mwSession_recv(struct mwSession *, const char *, gsize); | |
| | | | |
|
| /* primarily used by services to have messages serialized and sent */ | | /** primarily used by services to have messages serialized and sent */ | |
| int mwSession_send(struct mwSession *, struct mwMessage *); | | int mwSession_send(struct mwSession *, struct mwMessage *); | |
| | | | |
|
| /* set the internal privacy information, and inform the server as | | /** set the internal privacy information, and inform the server as | |
| necessary. Triggers the on_setPrivacyInfo call-back */ | | necessary. Triggers the on_setPrivacyInfo call-back */ | |
| int mwSession_setPrivacyInfo(struct mwSession *, struct mwPrivacyInfo *); | | int mwSession_setPrivacyInfo(struct mwSession *, struct mwPrivacyInfo *); | |
| | | | |
|
| /* set the internal user status state, and inform the server as | | /** set the internal user status state, and inform the server as | |
| necessary. Triggers the on_setUserStatus call-back */ | | necessary. Triggers the on_setUserStatus call-back */ | |
| int mwSession_setUserStatus(struct mwSession *, struct mwUserStatus *); | | int mwSession_setUserStatus(struct mwSession *, struct mwUserStatus *); | |
| | | | |
|
| /* a default call-back for the on_initConnect slot which composes and | | /** a call-back for use in the on_start slot which composes and sends | |
| sends a handshake message */ | | a handshake message */ | |
| void initConnect_sendHandshake(struct mwSession *); | | void onStart_sendHandshake(struct mwSession *); | |
| | | | |
|
| /* a default call-back for the on_handshake slot which composes and | | /** a call-back for use in the on_handshake slot which composes and | |
| sends a login message */ | | sends a login message */ | |
| void handshakeAck_sendLogin(struct mwSession *, struct mwMsgHandshakeAck *) | | void onHandshakeAck_sendLogin(struct mwSession *, struct mwMsgHandshakeAck | |
| ; | | *); | |
| | | | |
|
| | | /** adds a service to the session. If the session is started and the | |
| | | service has a start function, the session will request service | |
| | | availability form the server. On receipt of the service | |
| | | availability notification, the session will call the start | |
| | | function. */ | |
| int mwSession_putService(struct mwSession *, struct mwService *); | | int mwSession_putService(struct mwSession *, struct mwService *); | |
| | | | |
|
| | | /** obtain a reference to a mwService by its type identifier */ | |
| struct mwService *mwSession_getService(struct mwSession *, guint32 type); | | struct mwService *mwSession_getService(struct mwSession *, guint32 type); | |
| | | | |
|
| | | /** removes a service from the session. If the session is started and | |
| | | the service has a stop function, it will be called. */ | |
| int mwSession_removeService(struct mwSession *, guint32 type); | | int mwSession_removeService(struct mwSession *, guint32 type); | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 22 change blocks. |
| 42 lines changed or deleted | | 54 lines changed or added | |
|
| srvc_aware.h | | srvc_aware.h | |
| | | | |
| #ifndef _MW_SRVC_AWARE_H_ | | #ifndef _MW_SRVC_AWARE_H_ | |
| #define _MW_SRVC_AWARE_H_ | | #define _MW_SRVC_AWARE_H_ | |
| | | | |
| #include <glib/ghash.h> | | #include <glib/ghash.h> | |
| #include "common.h" | | #include "common.h" | |
| | | | |
|
| struct mwService; | | /** @struct mwServiceAware | |
| struct mwSession; | | Instance of an Aware Service. The members of this structure are | |
| | | not made available. Accessing the parts of an aware service should | |
| struct mwServiceAware { | | be performed through the appropriate functions. Note that | |
| struct mwService service; | | instances of this structure can be safely cast to a mwService. | |
| | | */ | |
| | | struct mwServiceAware; | |
| | | | |
|
| void (*got_aware)(struct mwServiceAware *, | | /** @struct mwAwareList | |
| struct mwSnapshotAwareIdBlock *, unsigned int); | | Instance of an Aware List. The members of this structure are not | |
| | | made available. Access to the parts of an aware list should be | |
| | | handled through the appropriate functions. | |
| | | */ | |
| | | struct mwAwareList; | |
| | | | |
|
| GHashTable *buddy_text; | | /** Appropriate function type for the on-aware signal | |
| }; | | @param list mwAwareList emiting the signal | |
| | | @param id awareness status information | |
| | | @param data user-specified data | |
| | | */ | |
| | | typedef void (*mwAwareList_onAwareHandler) | |
| | | (struct mwAwareList *list, | |
| | | struct mwSnapshotAwareIdBlock *id, | |
| | | gpointer data); | |
| | | | |
| struct mwServiceAware *mwServiceAware_new(struct mwSession *); | | struct mwServiceAware *mwServiceAware_new(struct mwSession *); | |
| | | | |
|
| int mwServiceAware_add(struct mwServiceAware *srvc, | | /** Allocate and initialize an aware list. */ | |
| struct mwIdBlock *list, unsigned int count); | | struct mwAwareList *mwAwareList_new(struct mwServiceAware *); | |
| | | | |
|
| int mwServiceAware_remove(struct mwServiceAware *srvc, | | /** Clean and free an aware list. Will remove all signal subscribers */ | |
| struct mwIdBlock *list, unsigned int count); | | void mwAwareList_free(struct mwAwareList *list); | |
| | | | |
|
| /* trigger a got_aware event constructed from the passed user and | | /** Add a collection of user IDs to an aware list. | |
| status information. Useful for adding false users and having the | | @param list mwAwareList to add user ID to | |
| getText function work for them */ | | @param id_list array of user IDs to add | |
| | | @param count number of members in id_list | |
| | | @return zero for success, non-zero to indicate an error. | |
| | | */ | |
| | | int mwAwareList_addAware(struct mwAwareList *list, | |
| | | struct mwAwareIdBlock *id_list, guint count); | |
| | | | |
| | | /** Remove a collection of user IDs from an aware list. | |
| | | @param list mwAwareList to add user ID to | |
| | | @param id_list array of user IDs to add | |
| | | @param count number of members in id_list | |
| | | @return zero for success, non-zero to indicate an error. | |
| | | */ | |
| | | int mwAwareList_removeAware(struct mwAwareList *list, | |
| | | struct mwAwareIdBlock *id_list, guint count); | |
| | | | |
| | | /** Utility function for registering a subscriber to the on-aware signal | |
| | | emitted by an aware list. | |
| | | @param list mwAwareList to listen for | |
| | | @param cb callback function | |
| | | @param data user-specific data to be passed along to cb | |
| | | */ | |
| | | void mwAwareList_setOnAware(struct mwAwareList *list, | |
| | | mwAwareList_onAwareHandler cb, gpointer data); | |
| | | | |
| | | /** trigger a got_aware event constructed from the passed user and | |
| | | status information. Useful for adding false users and having the | |
| | | getText function work for them */ | |
| void mwServiceAware_setStatus(struct mwServiceAware *srvc, | | void mwServiceAware_setStatus(struct mwServiceAware *srvc, | |
| struct mwAwareIdBlock *user, | | struct mwAwareIdBlock *user, | |
| struct mwUserStatus *stat); | | struct mwUserStatus *stat); | |
| | | | |
|
| /* look up the status description for a user */ | | /** look up the status description for a user */ | |
| const char *mwServiceAware_getText(struct mwServiceAware *srvc, | | const char *mwServiceAware_getText(struct mwServiceAware *srvc, | |
|
| struct mwIdBlock *user); | | struct mwAwareIdBlock *user); | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 8 change blocks. |
| 18 lines changed or deleted | | 58 lines changed or added | |
|