MCPcopy Create free account
hub / github.com/amule-project/amule / Process_Answer_v2

Method Process_Answer_v2

src/TextClient.cpp:739–975  ·  view source on GitHub ↗

* Format EC packet into text form for output to console */

Source from the content-addressed store, hash-verified

737 * Format EC packet into text form for output to console
738 */
739void CamulecmdApp::Process_Answer_v2(const CECPacket *response)
740{
741 wxString s;
742 wxString msgFailedUnknown(_("Request failed with an unknown error."));
743 wxASSERT(response);
744 switch (response->GetOpCode()) {
745 case EC_OP_NOOP:
746 s << _("Operation was successful.");
747 break;
748 case EC_OP_FAILED:
749 {
750 const CECTag *tag = response->GetFirstTagSafe();
751 if (tag->IsString()) {
752 s << CFormat(_("Request failed with the following error: %s")) % wxGetTranslation(tag->GetStringData());
753 } else {
754 s << msgFailedUnknown;
755 }
756 }
757 break;
758 case EC_OP_SET_PREFERENCES:
759 {
760 const CECTag *tab = response->GetTagByNameSafe(EC_TAG_PREFS_SECURITY);
761 const CECTag *ipfilterLevel = tab->GetTagByName(EC_TAG_IPFILTER_LEVEL);
762 if (ipfilterLevel) {
763 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
764 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
765 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_CLIENTS) {
766 s += CFormat(_("IP filtering for clients is %s.\n"))
767 % ((tab->GetTagByName(EC_TAG_IPFILTER_CLIENTS) == NULL) ? _("OFF") : _("ON"));
768 }
769 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
770 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE ||
771 m_last_cmd_id == CMD_ID_GET_IPFILTER_STATE_SERVERS) {
772 s += CFormat(_("IP filtering for servers is %s.\n"))
773 % ((tab->GetTagByName(EC_TAG_IPFILTER_SERVERS) == NULL) ? _("OFF") : _("ON"));
774 }
775 if (m_last_cmd_id == CMD_ID_GET_IPFILTER ||
776 m_last_cmd_id == CMD_ID_GET_IPFILTER_LEVEL) {
777 s << CFormat(_("Current IPFilter Level is %d.\n")) % ipfilterLevel->GetInt();
778 }
779 }
780 tab = response->GetTagByNameSafe(EC_TAG_PREFS_CONNECTIONS);
781 const CECTag *connMaxUL = tab->GetTagByName(EC_TAG_CONN_MAX_UL);
782 const CECTag *connMaxDL = tab->GetTagByName(EC_TAG_CONN_MAX_DL);
783 if (connMaxUL && connMaxDL) {
784 s << CFormat(_("Bandwidth limits: Up: %u kB/s, Down: %u kB/s.\n"))
785 % connMaxUL->GetInt() % connMaxDL->GetInt();
786 }
787 }
788 break;
789 case EC_OP_STRINGS:
790 for (CECPacket::const_iterator it = response->begin(); it != response->end(); ++it) {
791 const CECTag &tag = *it;
792 s << tag.GetStringData() << "\n";
793 }
794 break;
795 case EC_OP_STATS: {
796 const CEC_ConnState_Tag *connState = static_cast<const CEC_ConnState_Tag*>(response->GetTagByName(EC_TAG_CONNSTATE));

Callers

nothing calls this directly

Calls 15

CFormatClass · 0.85
CastItoSpeedFunction · 0.85
PriorityToStrFunction · 0.85
CastItoXBytesFunction · 0.85
StatTree2TextFunction · 0.85
GetFirstTagSafeMethod · 0.80
IsStringMethod · 0.80
GetStringDataMethod · 0.80
GetTagByNameSafeMethod · 0.80
GetTagByNameMethod · 0.80
StringIPMethod · 0.80
GetIPv4DataMethod · 0.80

Tested by

no test coverage detected