Example #1
0
  InSNAC* ParseSNAC(Buffer& b) {
    unsigned short family, subtype;
    b >> family
      >> subtype;

    InSNAC *snac = NULL;

    switch(family) {

    case SNAC_FAM_BOS:
      switch(subtype) {
	  case SNAC_BOS_Error:
	  snac = new ErrorInSNAC(family, subtype);
	  break;
      }
      break;
    case SNAC_FAM_GEN:
      switch(subtype) {
      case SNAC_GEN_ServerReady:
	snac = new ServerReadySNAC();
	break;
      case SNAC_GEN_RateInfo:
	snac = new RateInfoSNAC();
	break;
      case SNAC_GEN_CapAck:
	snac = new CapAckSNAC();
	break;
      case SNAC_GEN_UserInfo:
	snac = new UserInfoSNAC();
	break;
      case SNAC_GEN_MOTD:
	snac = new MOTDSNAC();
	break;
      case SNAC_GEN_RateInfoChange:
	snac = new RateInfoChangeSNAC();
	break;
      case SNAC_GEN_Error:
	snac = new ErrorInSNAC(family, subtype);
	break;
      }
      break;

    case SNAC_FAM_BUD:
      switch(subtype) {
      case SNAC_BUD_Online:
	snac = new BuddyOnlineSNAC();
	break;
      case SNAC_BUD_Offline:
	snac = new BuddyOfflineSNAC();
	break;
      case SNAC_BUD_Error:
	snac = new ErrorInSNAC(family, subtype);
	break;
      }
      break;

    case SNAC_FAM_MSG:
      switch(subtype) {
      case SNAC_MSG_Message:
	snac = new MessageSNAC();
	break;
      case SNAC_MSG_MessageACK:
	snac = new MessageACKSNAC();
	break;
      case SNAC_MSG_OfflineUser:
	snac = new MessageOfflineUserSNAC();
	break;
      case SNAC_MSG_TypingNotification:
        snac = new MessageTypingNotificationSNAC();
        break;
      case SNAC_MSG_Error:
	snac = new ErrorInSNAC(family, subtype);
	break;
      }
      break;

    case SNAC_FAM_SRV:
      switch(subtype) {
      case SNAC_SRV_Response:
	snac = new SrvResponseSNAC();
	break;
      case SNAC_SRV_Error:
	snac = new ErrorInSNAC(family, subtype);
	break;
      }
      break;

    case SNAC_FAM_UIN:
      switch(subtype) {
      case SNAC_UIN_RequestError:
	snac = new UINRequestErrorSNAC();
	break;
      case SNAC_UIN_Response:
	snac = new UINResponseSNAC();
	break;
      }
    
    case SNAC_FAM_SBL:
      switch(subtype) {
      case SNAC_SBL_Rights_Reply:
	snac = new SBLRightsReplySNAC();
	break;
      case SNAC_SBL_List_From_Server:
	snac = new SBLListSNAC();
	break;
      case SNAC_SBL_List_Unchanged:
	snac = new SBLListUnchangedSNAC();
	break;
      case SNAC_SBL_Edit_ACK:
	snac = new SBLEditACKSNAC();
	break;
      case SNAC_SBL_Auth_Request:
        snac = new SBLAuthRequestSNAC();
	break;
      case SNAC_SBL_Auth_Received:
        snac = new SBLAuthReceivedSNAC();
	break;
      case SNAC_SBL_User_Added_You:
	snac = new SBLUserAddedYouSNAC();
	break;
      case SNAC_SBL_Error:
	snac = new ErrorInSNAC(family, subtype);
	break;
      }
      break;
    }
    
    if (snac == NULL) {
      // unrecognised SNAC
      // parse as a RawSNAC
      snac = new RawSNAC(family, subtype);
    }

    snac->Parse(b);

    return snac;

  }
Example #2
0
  InSNAC* ParseSNAC(Buffer& b) {
    unsigned short family, subtype;
    b >> family
      >> subtype;

    InSNAC *snac = NULL;

    switch(family) {

    case SNAC_FAM_GEN:
      switch(subtype) {
      case SNAC_GEN_ServerReady:
	snac = new ServerReadySNAC();
	break;
      case SNAC_GEN_RateInfo:
	snac = new RateInfoSNAC();
	break;
      case SNAC_GEN_CapAck:
	snac = new CapAckSNAC();
	break;
      case SNAC_GEN_UserInfo:
	snac = new UserInfoSNAC();
	break;
      case SNAC_GEN_MOTD:
	snac = new MOTDSNAC();
	break;
      case SNAC_GEN_RateInfoChange:
	snac = new RateInfoChangeSNAC();
	break;
      }
      break;

    case SNAC_FAM_BUD:
      switch(subtype) {
      case SNAC_BUD_Online:
	snac = new BuddyOnlineSNAC();
	break;
      case SNAC_BUD_Offline:
	snac = new BuddyOfflineSNAC();
	break;
      }
      break;

    case SNAC_FAM_MSG:
      switch(subtype) {
      case SNAC_MSG_Message:
	snac = new MessageSNAC();
	break;
      case SNAC_MSG_MessageACK:
	snac = new MessageACKSNAC();
	break;
      case SNAC_MSG_OfflineUser:
	snac = new MessageOfflineUserSNAC();
	break;
      }
      break;

    case SNAC_FAM_SRV:
      switch(subtype) {
      case SNAC_SRV_Response:
	snac = new SrvResponseSNAC();
	break;
      }
      break;

    case SNAC_FAM_UIN:
      switch(subtype) {
      case SNAC_UIN_RequestError:
	snac = new UINRequestErrorSNAC();
	break;
      case SNAC_UIN_Response:
	snac = new UINResponseSNAC();
	break;
      }
    
    case SNAC_FAM_SBL:
      switch(subtype) {
      case SNAC_SBL_List_From_Server:
	snac = new SBLListSNAC();
	break;
      }
      break;
    }
    
    if (snac == NULL) {
      // unrecognised SNAC
      // parse as a RawSNAC
      snac = new RawSNAC(family, subtype);
    }

    snac->Parse(b);

    return snac;

  }