CSametimeProto* getProtoFromMwAwareList(mwAwareList* list) { mwServiceAware* servAwere = mwAwareList_getServiceAware(list); mwService* service = mwServiceAware_getService(servAwere); mwSession* session = mwService_getSession(service); return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); }
CSametimeProto* getProtoFromMwFileTransfer(mwFileTransfer* ft) { mwServiceFileTransfer* serviceFT = mwFileTransfer_getService(ft); mwService* service = mwServiceFileTransfer_getService(serviceFT); mwSession* session = mwService_getSession(service); return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); }
CSametimeProto* getProtoFromMwConference(mwConference* conf) { mwServiceConference* servConference = mwConference_getServiceConference(conf); mwService* service = mwServiceConference_getService(servConference); mwSession* session = mwService_getSession(service); return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); }
const char *mwPlace_getTitle(struct mwPlace *place) { g_return_val_if_fail(place != NULL, NULL); if(! place->title) { struct mwSession *session; struct mwLoginInfo *li; session = mwService_getSession(MW_SERVICE(place->service)); li = mwSession_getLoginInfo(session); place->title = place_generate_title(li? li->user_name: NULL); } return place->title; }
static struct mwChannel *make_channel(struct mwServiceDirectory *srvc) { struct mwSession *session; struct mwChannelSet *cs; struct mwChannel *chan; session = mwService_getSession(MW_SERVICE(srvc)); cs = mwSession_getChannels(session); chan = mwChannel_newOutgoing(cs); mwChannel_setService(chan, MW_SERVICE(srvc)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); return mwChannel_create(chan)? NULL: chan; }
static void ft_create_chan(struct mwFileTransfer *ft) { struct mwSession *s; struct mwChannelSet *cs; struct mwChannel *chan; struct mwLoginInfo *login; struct mwPutBuffer *b; /* we only should be calling this if there isn't a channel already associated with the conversation */ g_return_if_fail(ft != NULL); g_return_if_fail(mwFileTransfer_isNew(ft)); g_return_if_fail(ft->channel == NULL); s = mwService_getSession(MW_SERVICE(ft->service)); cs = mwSession_getChannels(s); chan = mwChannel_newOutgoing(cs); mwChannel_setService(chan, MW_SERVICE(ft->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); /* offer all known ciphers */ mwChannel_populateSupportedCipherInstances(chan); /* set the target */ login = mwChannel_getUser(chan); login->user_id = g_strdup(ft->who.user); login->community = g_strdup(ft->who.community); /* compose the addtl create */ b = mwPutBuffer_new(); guint32_put(b, 0x00); mwString_put(b, ft->filename); mwString_put(b, ft->message); guint32_put(b, ft->size); guint32_put(b, 0x00); guint16_put(b, 0x00); mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ft->channel = mwChannel_create(chan)? NULL: chan; if(ft->channel) { mwChannel_setServiceData(ft->channel, ft, NULL); } }
int mwConference_open(struct mwConference *conf) { struct mwSession *session; struct mwChannel *chan; struct mwPutBuffer *b; int ret; g_return_val_if_fail(conf != NULL, -1); g_return_val_if_fail(conf->service != NULL, -1); g_return_val_if_fail(conf->state == mwConference_NEW, -1); g_return_val_if_fail(conf->channel == NULL, -1); session = mwService_getSession(MW_SERVICE(conf->service)); g_return_val_if_fail(session != NULL, -1); if(! conf->name) { char *user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); conf->name = conf_generate_name(user? user: "******"); } chan = mwChannel_newOutgoing(mwSession_getChannels(session)); mwChannel_setService(chan, MW_SERVICE(conf->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); #if 0 /* offer all known ciphers */ mwChannel_populateSupportedCipherInstances(chan); #endif b = mwPutBuffer_new(); mwString_put(b, conf->name); mwString_put(b, conf->title); guint32_put(b, 0x00); mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ret = mwChannel_create(chan); if(ret) { conf_state(conf, mwConference_ERROR); } else { conf_state(conf, mwConference_PENDING); conf->channel = chan; } return ret; }
static struct mwConference *conf_new(struct mwServiceConference *srvc) { struct mwConference *conf; struct mwSession *session; const char *user; conf = g_new0(struct mwConference, 1); conf->state = mwConference_NEW; conf->service = srvc; conf->members = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) login_free); session = mwService_getSession(MW_SERVICE(srvc)); user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); srvc->confs = g_list_prepend(srvc->confs, conf); return conf; }
static void recv_channelDestroy(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelDestroy *msg) { struct mwSession *session; struct mwServiceStorage *srvc_stor; g_return_if_fail(srvc != NULL); g_return_if_fail(chan != NULL); session = mwService_getSession(srvc); g_return_if_fail(session != NULL); srvc_stor = (struct mwServiceStorage *) srvc; srvc_stor->channel = NULL; mwService_stop(srvc); mwSession_senseService(session, mwService_getType(srvc)); }
int mwPlace_open(struct mwPlace *p) { struct mwSession *session; struct mwChannelSet *cs; struct mwChannel *chan; struct mwPutBuffer *b; int ret; g_return_val_if_fail(p != NULL, -1); g_return_val_if_fail(p->service != NULL, -1); session = mwService_getSession(MW_SERVICE(p->service)); g_return_val_if_fail(session != NULL, -1); cs = mwSession_getChannels(session); g_return_val_if_fail(cs != NULL, -1); chan = mwChannel_newOutgoing(cs); mwChannel_setService(chan, MW_SERVICE(p->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); mwChannel_populateSupportedCipherInstances(chan); b = mwPutBuffer_new(); mwString_put(b, mwPlace_getName(p)); mwString_put(b, mwPlace_getTitle(p)); guint32_put(b, 0x00); /* ? */ mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ret = mwChannel_create(chan); if(ret) { place_state(p, mwPlace_ERROR); } else { place_state(p, mwPlace_PENDING); p->channel = chan; mwChannel_setServiceData(chan, p, NULL); } return ret; }
CSametimeProto* getProtoFromMwServiceResolve(mwServiceResolve* srvcResolve) { mwService* service = mwServiceResolve_getService(srvcResolve); mwSession* session = mwService_getSession(service); return (CSametimeProto*)mwSession_getProperty(session, "PROTO_STRUCT_PTR"); }