static void recv_channelDestroy(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelDestroy *msg) { /* - find conference from channel - trigger got_closed - remove conference, dealloc */ struct mwServiceConference *srvc_conf = (struct mwServiceConference *) srvc; struct mwConference *conf = conf_find(srvc_conf, chan); struct mwConferenceHandler *h = srvc_conf->handler; /* if there's no such conference, then I guess there's nothing to worry about. Except of course for the fact that we should never receive a channel destroy for a conference that doesn't exist. */ if(! conf) return; conf->channel = NULL; conf_state(conf, msg->reason? mwConference_ERROR: mwConference_CLOSING); if(h->conf_closed) h->conf_closed(conf, msg->reason); mwConference_destroy(conf, ERR_SUCCESS, NULL); }
void CSametimeProto::DeinitConference() { GList *conferences, *conf; debugLog(_T("CSametimeProto::DeinitConference()")); if (service_conference){ conferences = conf = mwServiceConference_getConferences(service_conference); for (;conf;conf = conf->next) { if (my_conference == conf->data) CloseMyConference(this); else { char* utfs = mir_utf8encodeT(TranslateT("I'm outa here.")); mwConference_destroy((mwConference*)conf->data, 0, utfs); mir_free(utfs); } } g_list_free(conferences); } my_login_info = 0; mwSession_removeService(session, mwService_CONFERENCE); if (service_conference){ mwService_free((mwService*)service_conference); service_conference = 0; } }
static void WELCOME_recv(struct mwServiceConference *srvc, struct mwConference *conf, struct mwGetBuffer *b) { struct mwConferenceHandler *h; guint16 tmp16; guint32 tmp32; guint32 count; GList *l = NULL; /* re-read name and title */ g_free(conf->name); g_free(conf->title); conf->name = NULL; conf->title = NULL; mwString_get(b, &conf->name); mwString_get(b, &conf->title); /* some numbers we don't care about, then a count of members */ guint16_get(b, &tmp16); guint32_get(b, &tmp32); guint32_get(b, &count); if(mwGetBuffer_error(b)) { g_warning("error parsing welcome message for conference"); mwConference_destroy(conf, ERR_FAILURE, NULL); return; } while(count--) { guint16 member_id; struct mwLoginInfo *member = g_new0(struct mwLoginInfo, 1); guint16_get(b, &member_id); mwLoginInfo_get(b, member); if(mwGetBuffer_error(b)) { login_free(member); break; } MEMBER_ADD(conf, member_id, member); l = g_list_append(l, member); } conf_state(conf, mwConference_OPEN); h = srvc->handler; if(h->conf_opened) h->conf_opened(conf, l); /* get rid of the GList, but not its contents */ g_list_free(l); }
static void recv_channelCreate(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelCreate *msg) { /* - this is how we really receive invitations - create a conference and associate it with the channel - obtain the invite data from the msg addtl info - mark the conference as INVITED - trigger the got_invite event */ struct mwServiceConference *srvc_conf = (struct mwServiceConference *) srvc; struct mwConference *conf; struct mwGetBuffer *b; char *invite = NULL; guint tmp; conf = conf_new(srvc_conf); conf->channel = chan; b = mwGetBuffer_wrap(&msg->addtl); guint32_get(b, &tmp); mwString_get(b, &conf->name); mwString_get(b, &conf->title); guint32_get(b, &tmp); mwLoginInfo_get(b, &conf->owner); guint32_get(b, &tmp); mwString_get(b, &invite); if(mwGetBuffer_error(b)) { g_warning("failure parsing addtl for conference invite"); mwConference_destroy(conf, ERR_FAILURE, NULL); } else { struct mwConferenceHandler *h = srvc_conf->handler; conf_state(conf, mwConference_INVITED); if(h->on_invited) h->on_invited(conf, &conf->owner, invite); } mwGetBuffer_free(b); g_free(invite); }
int CSametimeProto::GcEventHook(WPARAM wParam, LPARAM lParam) { GCHOOK* gch = (GCHOOK*)lParam; if (strcmp(gch->pDest->pszModule, m_szModuleName) != 0) return 0; GList *conferences, *conf; conferences = conf = mwServiceConference_getConferences(service_conference); for (;conf;conf = conf->next) { TCHAR* tszConfId = mir_utf8decodeT(mwConference_getName((mwConference*)conf->data)); if (_tcscmp(gch->pDest->ptszID, tszConfId) == 0) { switch(gch->pDest->iType) { case GC_USER_MESSAGE: { debugLog(_T("CSametimeProto::GcEventHook() GC_USER_MESSAGE")); char* utf_msg; utf_msg = mir_utf8encodeT(gch->ptszText); mwConference_sendText((mwConference*)conf->data, utf_msg); mir_free(utf_msg); } break; case GC_SESSION_TERMINATE: { if (my_conference == conf->data){ debugLog(_T("CSametimeProto::GcEventHook() GC_SESSION_TERMINATE CloseMyConference")); CloseMyConference(this); } else { debugLog(_T("CSametimeProto::GcEventHook() GC_SESSION_TERMINATE mwConference_destroy")); char* utfs = mir_utf8encodeT(TranslateT("I'm outa here.")); mwConference_destroy((mwConference*)conf->data, 0, utfs); mir_free(utfs); } } break; } break; } mir_free(tszConfId); } g_list_free(conferences); return 0; }
static void stop(struct mwServiceConference *srvc) { while(srvc->confs) mwConference_destroy(srvc->confs->data, ERR_SUCCESS, NULL); mwService_stopped(MW_SERVICE(srvc)); }
void CloseMyConference(CSametimeProto* proto) { mwConference_destroy(proto->my_conference, 0, Translate("I'm outa here.")); proto->my_conference = 0; }