} // picture2() /// <summary> /// /// </summary> /// <param name="major_id"></param> /// <param name="minor_id"></param> /// <returns></returns> public int picture_bad2(int major_id, int minor_id) { CCProtoPacket pack = new CCProtoPacket(); pack.Command = CCProtoPacket.cmdCC_PICTUREFL; CCPictDescr desc = new CCPictDescr(); desc.setTimeout(APIConstants.ptoDEFAULT); desc.setType(APIConstants.ptUNSPECIFIED); desc.setMajorID(major_id); desc.setMinorID(minor_id); desc.calcSize(); pack.setData(desc.pack()); pack.calcSize(); if (pack.PackTo(_stream) == false) { return(APIConstants.ccERR_NET_ERROR); } return(APIConstants.ccERR_NET_ERROR); } // picture_bad2()
} // picture2() /// <summary> /// /// </summary> /// <param name="major_id"></param> /// <param name="minor_id"></param> /// <returns></returns> public int picture_bad2(int major_id, int minor_id) { CCProtoPacket pack = new CCProtoPacket(); pack.Command = CCProtoPacket.cmdCC_PICTUREFL; CCPictDescr desc = new CCPictDescr(); desc.setTimeout(APIConstants.ptoDEFAULT); desc.setType(APIConstants.ptUNSPECIFIED); desc.setMajorID(major_id); desc.setMinorID(minor_id); desc.calcSize(); pack.setData(desc.pack()); pack.calcSize(); if (pack.PackTo(_stream) == false) { return APIConstants.ccERR_NET_ERROR; } return APIConstants.ccERR_NET_ERROR; } // picture_bad2()
/// <summary> say "thanks" to Java incapability to pass values by reference in order to use them as multiple returns all arrays[] are used as workarond to get values out of the function, really </summary> /// <param name="pict"></param> /// <param name="pict_to"></param> /// <param name="pict_type"></param> /// <param name="text"></param> /// <param name="major_id"></param> /// <param name="minor_id"></param> /// <returns></returns> public int picture2( byte[] pict, // IN picture binary data int[] pict_to, // IN/OUT timeout specifier to be used, on return - really used specifier, see ptoXXX constants, ptoDEFAULT in case of unrecognizable int[] pict_type, // IN/OUT type specifier to be used, on return - really used specifier, see ptXXX constants, ptUNSPECIFIED in case of unrecognizable String[] text, // OUT text int[] major_id, // OUT OPTIONAL major part of the picture ID int[] minor_id // OUT OPTIONAL minor part of the picture ID ) { if (_status != sCCC_PICTURE) return APIConstants.ccERR_STATUS; CCProtoPacket pack = new CCProtoPacket(); pack.Command = CCProtoPacket.cmdCC_PICTURE2; CCPictDescr desc = new CCPictDescr(); desc.setTimeout(pict_to[0]); desc.setType(pict_type[0]); desc.setMajorID(0); desc.setMinorID(0); desc.setData(pict); desc.calcSize(); pack.setData(desc.pack()); pack.calcSize(); if (pack.PackTo(_stream) == false) { return APIConstants.ccERR_NET_ERROR; } if (pack.UnpackFrom(_stream, -1, -1) == false) { return APIConstants.ccERR_NET_ERROR; } switch (pack.Command) { case CCProtoPacket.cmdCC_TEXT2: desc.unpack(pack.getData()); pict_to[0] = desc.getTimeout(); pict_type[0] = desc.getType(); text[0] = desc.getData() == null ? "" : Encoding.ASCII.GetString(desc.getData()); if (major_id != null) major_id[0] = desc.getMajorID(); if (minor_id != null) minor_id[0] = desc.getMinorID(); return APIConstants.ccERR_OK; case CCProtoPacket.cmdCC_BALANCE: // balance depleted return APIConstants.ccERR_BALANCE; case CCProtoPacket.cmdCC_OVERLOAD: // server's busy return APIConstants.ccERR_OVERLOAD; case CCProtoPacket.cmdCC_TIMEOUT: // picture timed out return APIConstants.ccERR_TIMEOUT; case CCProtoPacket.cmdCC_FAILED: // server's error return APIConstants.ccERR_GENERAL; default: // unknown error return APIConstants.ccERR_UNKNOWN; } } // picture2()
/// <summary> say "thanks" to Java incapability to pass values by reference in order to use them as multiple returns all arrays[] are used as workarond to get values out of the function, really </summary> /// <param name="pict"></param> /// <param name="pict_to"></param> /// <param name="pict_type"></param> /// <param name="text"></param> /// <param name="major_id"></param> /// <param name="minor_id"></param> /// <returns></returns> public int picture2( byte[] pict, // IN picture binary data int[] pict_to, // IN/OUT timeout specifier to be used, on return - really used specifier, see ptoXXX constants, ptoDEFAULT in case of unrecognizable int[] pict_type, // IN/OUT type specifier to be used, on return - really used specifier, see ptXXX constants, ptUNSPECIFIED in case of unrecognizable String[] text, // OUT text int[] major_id, // OUT OPTIONAL major part of the picture ID int[] minor_id // OUT OPTIONAL minor part of the picture ID ) { if (_status != sCCC_PICTURE) { return(APIConstants.ccERR_STATUS); } CCProtoPacket pack = new CCProtoPacket(); pack.Command = CCProtoPacket.cmdCC_PICTURE2; CCPictDescr desc = new CCPictDescr(); desc.setTimeout(pict_to[0]); desc.setType(pict_type[0]); desc.setMajorID(0); desc.setMinorID(0); desc.setData(pict); desc.calcSize(); pack.setData(desc.pack()); pack.calcSize(); if (pack.PackTo(_stream) == false) { return(APIConstants.ccERR_NET_ERROR); } if (pack.UnpackFrom(_stream, -1, -1) == false) { return(APIConstants.ccERR_NET_ERROR); } switch (pack.Command) { case CCProtoPacket.cmdCC_TEXT2: desc.unpack(pack.getData()); pict_to[0] = desc.getTimeout(); pict_type[0] = desc.getType(); text[0] = desc.getData() == null ? "" : Encoding.ASCII.GetString(desc.getData()); if (major_id != null) { major_id[0] = desc.getMajorID(); } if (minor_id != null) { minor_id[0] = desc.getMinorID(); } return(APIConstants.ccERR_OK); case CCProtoPacket.cmdCC_BALANCE: // balance depleted return(APIConstants.ccERR_BALANCE); case CCProtoPacket.cmdCC_OVERLOAD: // server's busy return(APIConstants.ccERR_OVERLOAD); case CCProtoPacket.cmdCC_TIMEOUT: // picture timed out return(APIConstants.ccERR_TIMEOUT); case CCProtoPacket.cmdCC_FAILED: // server's error return(APIConstants.ccERR_GENERAL); default: // unknown error return(APIConstants.ccERR_UNKNOWN); } } // picture2()