| 125 | |
| 126 | |
| 127 | bool ConnInfoUI::SaveConfig( const std::string& path ) |
| 128 | { |
| 129 | std::size_t theSize = m_dicServerInfo[kServerNameIndex].size(); |
| 130 | |
| 131 | FILE* fp = fopen(kConfigFilePath, "w+"); |
| 132 | if (!fp) |
| 133 | { |
| 134 | UserMessageBox(GetHWND(), 20003, NULL, MB_ICONERROR); |
| 135 | return false; |
| 136 | } |
| 137 | FileStream os(fp); |
| 138 | PrettyWriter<FileStream> writer(os); |
| 139 | writer.StartObject(); |
| 140 | writer.String("Server"); |
| 141 | writer.StartArray(); |
| 142 | for (std::size_t idx=0; idx<theSize; ++idx) |
| 143 | { |
| 144 | writer.StartObject(); |
| 145 | writer.String("name"); |
| 146 | CDuiString name = Base::CharacterSet::ANSIToUnicode(m_dicServerInfo[kServerNameIndex][idx]).c_str(); |
| 147 | |
| 148 | writer.String(Base::CharacterSet::UnicodeToUTF8(name.GetData()).c_str()); |
| 149 | writer.String("ip"); |
| 150 | writer.String(m_dicServerInfo[kServerIpIndex][idx].c_str(), m_dicServerInfo[kServerIpIndex][idx].length()); |
| 151 | writer.String("port"); |
| 152 | writer.Int(atoi(m_dicServerInfo[kServerPortIndex][idx].c_str())); |
| 153 | writer.String("auth"); |
| 154 | writer.String(m_dicServerInfo[kServerAuthIndex][idx].c_str()); |
| 155 | writer.EndObject(); |
| 156 | } |
| 157 | writer.EndArray(); |
| 158 | writer.EndObject(); |
| 159 | fclose(fp); |
| 160 | return true; |
| 161 | } |
| 162 | |
| 163 | |
| 164 | LPCTSTR ConnInfoUI::GetItemText( CControlUI* pControl, int iIndex, int iSubItem ) |
nothing calls this directly
no test coverage detected