Ticket #2361: ReduceCodeDuplication.patch

File ReduceCodeDuplication.patch, 2.0 KB (added by eyebex, 10 years ago)
  • MainFrm.cpp

     
    213213    SetStatusbarText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_RECVRATE), "0 B/s");
    214214    SetStatusbarText(m_wndStatusBar.CommandToIndex(ID_INDICATOR_SENDRATE), "0 B/s");
    215215
     216    CConnectDialog dlg(m_pOptions);
     217    if (!m_pOptions->GetOptionVal(IOPTION_ALWAYS) && dlg.DoModal() != IDOK)
     218        return 0;
    216219
    217     if (m_pOptions->GetOptionVal(IOPTION_ALWAYS))
     220    m_pAdminSocket = new CAdminSocket(this);
     221    ShowStatus("Connecting to server...", 0);
     222    m_pAdminSocket->Create();
     223    m_pAdminSocket->m_Password = m_pOptions->GetOption(IOPTION_LASTSERVERPASS);
     224    if (!m_pAdminSocket->Connect(m_pOptions->GetOption(IOPTION_LASTSERVERADDRESS), (UINT)m_pOptions->GetOptionVal(IOPTION_LASTSERVERPORT)) && WSAGetLastError() != WSAEWOULDBLOCK)
    218225    {
    219         m_pAdminSocket = new CAdminSocket(this);
    220         ShowStatus("Connecting to server...", 0);
    221         m_pAdminSocket->Create();
    222         m_pAdminSocket->m_Password = m_pOptions->GetOption(IOPTION_LASTSERVERPASS);
    223         if (!m_pAdminSocket->Connect(m_pOptions->GetOption(IOPTION_LASTSERVERADDRESS), (UINT)m_pOptions->GetOptionVal(IOPTION_LASTSERVERPORT)) && WSAGetLastError() != WSAEWOULDBLOCK)
    224         {
    225             ShowStatus(_T("Error, could not connect to server"), 1);
    226             CloseAdminSocket();
    227         }
     226        ShowStatus(_T("Error, could not connect to server"), 1);
     227        CloseAdminSocket();
    228228    }
    229     else
    230     {
    231         CConnectDialog dlg(m_pOptions);
    232         if (dlg.DoModal() == IDOK)
    233         {
    234             m_pAdminSocket = new CAdminSocket(this);
    235             ShowStatus("Connecting to server...", 0);
    236             m_pAdminSocket->m_Password = m_pOptions->GetOption(IOPTION_LASTSERVERPASS);
    237             m_pAdminSocket->Create();
    238             if (!m_pAdminSocket->Connect(m_pOptions->GetOption(IOPTION_LASTSERVERADDRESS), (UINT)m_pOptions->GetOptionVal(IOPTION_LASTSERVERPORT)) && WSAGetLastError()!=WSAEWOULDBLOCK)
    239             {
    240                 ShowStatus(_T("Error, could not connect to server"), 1);
    241                 CloseAdminSocket();
    242             }
    243         }
    244     }
    245229
    246230    return 0;
    247231}