Beispiel #1
0
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;
}
Beispiel #2
0
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);
  }
}
Beispiel #3
0
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;
}
Beispiel #4
0
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;
}