| 131 | |
| 132 | |
| 133 | void CCatDialog::OnBnClickedOk(wxCommandEvent& WXUNUSED(evt)) |
| 134 | { |
| 135 | wxString newname = CastChild(IDC_TITLE, wxTextCtrl)->GetValue(); |
| 136 | |
| 137 | // No empty names |
| 138 | if (newname.IsEmpty()) { |
| 139 | wxMessageBox( |
| 140 | _("You must specify a name for the category!"), |
| 141 | _("Info"), wxOK, this); |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | CPath newpath = CPath(CastChild(IDC_INCOMING, wxTextCtrl)->GetValue()); |
| 146 | |
| 147 | // No empty dirs please |
| 148 | if (!newpath.IsOk()) { |
| 149 | wxMessageBox( |
| 150 | _("You must specify a path for the category!"), |
| 151 | _("Info"), wxOK, this); |
| 152 | |
| 153 | return; |
| 154 | } |
| 155 | |
| 156 | // remote gui: |
| 157 | // Pass path unchecked (and don't try to create it on the wrong machine...). |
| 158 | // It will be checked on the server, and an error message created. |
| 159 | #ifndef CLIENT_GUI |
| 160 | if (!newpath.DirExists()) { |
| 161 | if (!CPath::MakeDir(newpath)) { |
| 162 | wxMessageBox(_("Failed to create incoming dir for category. Please specify a valid path!"), |
| 163 | _("Info"), wxOK, this); |
| 164 | return; |
| 165 | } |
| 166 | } |
| 167 | #endif |
| 168 | |
| 169 | // Check if we are using an existing category, and if we are, if it has |
| 170 | // been removed in the mean-while. Otherwise create new category. |
| 171 | // lfroen: The only place where it could happen, is removing category |
| 172 | // from remote gui, while local gui amule have dialog opened in this |
| 173 | // category. |
| 174 | int index = -1; |
| 175 | if (m_category) { |
| 176 | // Check if the original category still exists |
| 177 | bool found = false; |
| 178 | for (uint32 i = 0; i < theApp->glob_prefs->GetCatCount(); ++i) { |
| 179 | if (m_category == theApp->glob_prefs->GetCategory(i)) { |
| 180 | found = true; |
| 181 | index = i; |
| 182 | break; |
| 183 | } |
| 184 | } |
| 185 | if (!found) { |
| 186 | m_category = 0; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | if (!m_category) { |
nothing calls this directly
no test coverage detected