X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditorIM.cpp;h=cfee2d3125ae1432e5fba2c0e7e35dcbecd2351b;hp=adffd154d2cdf501e431711a80b4db4c4f955c61;hb=ada42724cf083b0a311cf22260485d61516c25c8;hpb=da64d37d0a13895554e4ad945c46dd0af6d1c0e6 diff --git a/source/contacteditor/frmContactEditorIM.cpp b/source/contacteditor/frmContactEditorIM.cpp index adffd15..cfee2d3 100644 --- a/source/contacteditor/frmContactEditorIM.cpp +++ b/source/contacteditor/frmContactEditorIM.cpp @@ -26,8 +26,13 @@ frmContactEditorIM::frmContactEditorIM( wxWindow* parent ) : frmContactEditorIMADT( parent ) { + + // Setup the window. + EditorMode = FALSE; - sliPriority->Disable(); + priorityCtrl = new XABPriorityCtrl(tabGeneral); + szrGeneral->Add(priorityCtrl, 1, wxEXPAND, 5); + szrGeneral->Layout(); // Add some values to the drop down box for IM types. @@ -37,21 +42,15 @@ frmContactEditorIMADT( parent ) cmbIMType->Append(wxT("Skype")); cmbIMType->Append(wxT("XMPP")); cmbIMType->Append(wxT("Yahoo")); + cmbIMType->Append(_("Other")); } -void frmContactEditorIM::EnablePriority( wxCommandEvent& event ) -{ - if (chkUsePref->IsChecked()){ - sliPriority->Enable(); - } else { - sliPriority->Disable(); - } -} - void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) { + // Process the action. + long ListCtrlIndex; // Check if IM type is empty and if it is then @@ -81,8 +80,7 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) // Add the address to the list (maps). wxString strIMAddress; - wxString strValue; - + // Strip out the colons. strIMAddress.Replace(wxT(":"), wxT(""), TRUE); @@ -93,38 +91,36 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) if (strIMTypeValue == wxT("AIM")){ - strIMAddress.Append(wxT("aim:")); + strIMAddress.Append(wxT("aim")); } else if (strIMTypeValue == wxT("Gadu-Gadu")){ - strIMAddress.Append(wxT("gg:")); + strIMAddress.Append(wxT("gg")); } else if (strIMTypeValue == wxT("ICQ")){ - strIMAddress.Append(wxT("icq:")); + strIMAddress.Append(wxT("icq")); } else if (strIMTypeValue == wxT("Skype")){ - strIMAddress.Append(wxT("skype:")); + strIMAddress.Append(wxT("skype")); } else if (strIMTypeValue == wxT("XMPP")){ - strIMAddress.Append(wxT("xmpp:")); + strIMAddress.Append(wxT("xmpp")); } else if (strIMTypeValue == wxT("Yahoo")){ - strIMAddress.Append(wxT("yahoo:")); + strIMAddress.Append(wxT("yahoo")); } else { - strIMAddress.Append(strIMTypeValue + wxT(":")); + strIMAddress.Append(strIMTypeValue); } - strIMAddress.Append(strValue); - strIMAddress.Append(txtUsername->GetValue()); - - IMListPtr->insert(std::make_pair(IMListIndex, strIMAddress)); + IMListTypeInfoPtr->insert(std::make_pair(IMListIndex, strIMAddress)); + IMListPtr->insert(std::make_pair(IMListIndex, txtUsername->GetValue())); // Set the type. @@ -144,9 +140,9 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) // Set the priority. - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - IMListPrefPtr->insert(std::make_pair(IMListIndex, sliPriority->GetValue())); + IMListPrefPtr->insert(std::make_pair(IMListIndex, priorityCtrl->GetValue())); } else { @@ -165,9 +161,9 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) IMListCtrlPtr->SetItem(ListCtrlIndex, 1, txtUsername->GetValue()); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - IMListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + IMListCtrlPtr->SetItem(ListCtrlIndex, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } @@ -178,60 +174,55 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) // Edit the address in the list. wxString strIMAddress; - wxString strValue; long longSelected = -1; - // Strip out the colons. - - strIMAddress.Replace(wxT(":"), wxT(""), TRUE); - // Specify the type. strIMTypeValue = cmbIMType->GetString(cmbIMType->GetSelection()); - + if (strIMTypeValue == wxT("AIM")){ - strIMAddress.Append(wxT("aim:")); + strIMAddress.Append(wxT("aim")); } else if (strIMTypeValue == wxT("Gadu-Gadu")){ - strIMAddress.Append(wxT("gg:")); + strIMAddress.Append(wxT("gg")); } else if (strIMTypeValue == wxT("ICQ")){ - strIMAddress.Append(wxT("icq:")); + strIMAddress.Append(wxT("icq")); } else if (strIMTypeValue == wxT("Skype")){ - strIMAddress.Append(wxT("skype:")); + strIMAddress.Append(wxT("skype")); } else if (strIMTypeValue == wxT("XMPP")){ - strIMAddress.Append(wxT("xmpp:")); + strIMAddress.Append(wxT("xmpp")); } else if (strIMTypeValue == wxT("Yahoo")){ - strIMAddress.Append(wxT("yahoo:")); + strIMAddress.Append(wxT("yahoo")); } else { - strIMAddress.Append(strIMTypeValue + wxT(":")); + strIMAddress.Append(strIMTypeValue); } - - strIMAddress.Append(strValue); - strIMAddress.Append(txtUsername->GetValue()); - + IMListPtr->erase(IMListIndex); - IMListPtr->insert(std::make_pair(IMListIndex, strIMAddress)); + IMListPtr->insert(std::make_pair(IMListIndex, txtUsername->GetValue())); + + IMListTypeInfoPtr->erase(IMListIndex); + IMListTypeInfoPtr->insert(std::make_pair(IMListIndex, strIMAddress)); // Set the priority. IMListPrefPtr->erase(IMListIndex); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - IMListPrefPtr->insert(std::make_pair(IMListIndex, sliPriority->GetValue())); + IMListPrefPtr->insert(std::make_pair(IMListIndex, priorityCtrl->GetValue())); } else { @@ -252,9 +243,9 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) IMListCtrlPtr->SetItem(longSelected, 0, cmbIMType->GetValue()); IMListCtrlPtr->SetItem(longSelected, 1, txtUsername->GetValue()); - if (chkUsePref->IsChecked()){ + if (priorityCtrl->IsPriorityChecked()){ - IMListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), sliPriority->GetValue())); + IMListCtrlPtr->SetItem(longSelected, 2, wxString::Format(wxT("%i"), priorityCtrl->GetValue())); } else { @@ -270,11 +261,18 @@ void frmContactEditorIM::ProcessAction( wxCommandEvent& event ) void frmContactEditorIM::CloseWindow( wxCommandEvent& event ) { + + // Close the window. + this->Close(); + } void frmContactEditorIM::SetEditorMode(bool EditMode, SectionType SectType) { + + // Set the editor mode. + // Set if the editor is adding or editing an address. // FALSE = Add // TRUE = Edit @@ -296,8 +294,8 @@ void frmContactEditorIM::SetEditorMode(bool EditMode, SectionType SectType) wxString strValue; wxString strIMType; wxString strIMUser; - - // Setup the IM Type. + + // Setup the IM Type. striter = IMListPtr->find(IMListIndex); @@ -305,39 +303,54 @@ void frmContactEditorIM::SetEditorMode(bool EditMode, SectionType SectType) strValue = striter->second; - } + } + + if (IMListPtr->find(IMListIndex) != IMListPtr->end()){ + + strIMUser = IMListPtr->find(IMListIndex)->second; + + } - wxStringTokenizer IMAddressToken(strValue, wxT(":")); - strIMType = IMAddressToken.GetNextToken(); - strIMUser = IMAddressToken.GetNextToken(); + if (IMListTypeInfoPtr->find(IMListIndex) != IMListTypeInfoPtr->end()){ + + strIMType = IMListTypeInfoPtr->find(IMListIndex)->second; + + } if (strIMType == wxT("aim")){ cmbIMType->SetValue(wxT("AIM")); + cmbIMType->SetSelection(0); } else if (strIMType == wxT("gg")){ cmbIMType->SetValue(wxT("Gadu-Gadu")); + cmbIMType->SetSelection(1); } else if (strIMType == wxT("icq")){ cmbIMType->SetValue(wxT("ICQ")); + cmbIMType->SetSelection(2); } else if (strIMType == wxT("skype")){ cmbIMType->SetValue(wxT("Skype")); + cmbIMType->SetSelection(3); } else if (strIMType == wxT("xmpp")){ - cmbIMType->SetValue(wxT("XMPP")); + cmbIMType->SetValue(wxT("XMPP")); + cmbIMType->SetSelection(4); } else if (strIMType == wxT("yahoo")){ cmbIMType->SetValue(wxT("Yahoo")); + cmbIMType->SetSelection(5); } else { cmbIMType->SetValue(strIMType); + cmbIMType->SetSelection(6); } @@ -349,11 +362,11 @@ void frmContactEditorIM::SetEditorMode(bool EditMode, SectionType SectType) intiter = IMListPrefPtr->find(IMListIndex); - if (intiter->first == IMListIndex && intiter->second > 0){ + if (intiter->first == IMListIndex && intiter->second > 0 && + intiter != IMListPrefPtr->end()){ - sliPriority->SetValue(intiter->second); - sliPriority->Enable(); - chkUsePref->SetValue(TRUE); + priorityCtrl->SetValue(intiter->second); + priorityCtrl->EnablePriority(true); } @@ -367,6 +380,7 @@ void frmContactEditorIM::SetupPointers( std::map *IMList, std::map *IMListAltID, std::map *IMListPID, std::map *IMListType, + std::map *IMListTypeInfo, std::map *IMListTokens, std::map *IMListMediatype, std::map *IMListPref, @@ -374,10 +388,13 @@ void frmContactEditorIM::SetupPointers( std::map *IMList, int IMIndex ) { + // Setup the pointers. + IMListPtr = IMList; IMListAltIDPtr = IMListAltID; IMListPIDPtr = IMListPID; IMListTypePtr = IMListType; + IMListTypeInfoPtr = IMListTypeInfo; IMListTokensPtr = IMListTokens; IMListMediatypePtr = IMListMediatype; IMListPrefPtr = IMListPref;