Subversion Repositories tpanel

Rev

Rev 396 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 396 Rev 400
Line 6963... Line 6963...
6963
    }
6963
    }
6964
 
6964
 
6965
    return 0;
6965
    return 0;
6966
}
6966
}
6967
 
6967
 
-
 
6968
void TButton::setUserName(const string& user)
-
 
6969
{
-
 
6970
    DECL_TRACER("TButton::setUserName(const string& user)");
-
 
6971
 
-
 
6972
    if (TConfig::getUserPassword(user).empty())
-
 
6973
        return;
-
 
6974
 
-
 
6975
    mUser = user;
-
 
6976
}
-
 
6977
 
6968
void TButton::calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY)
6978
void TButton::calcImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY)
6969
{
6979
{
6970
    DECL_TRACER("TButton::clacImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY)");
6980
    DECL_TRACER("TButton::clacImageSizePercent(int imWidth, int imHeight, int btWidth, int btHeight, int btFrame, int *realX, int *realY)");
6971
 
6981
 
6972
    int spX = btWidth - (btFrame * 2);
6982
    int spX = btWidth - (btFrame * 2);
Line 7856... Line 7866...
7856
 
7866
 
7857
    // If the button is marked as password protected, then we must display
7867
    // If the button is marked as password protected, then we must display
7858
    // a window with an input line to get the password from the user. Only if
7868
    // a window with an input line to get the password from the user. Only if
7859
    // the password is equal to the password in the setup the button is
7869
    // the password is equal to the password in the setup the button is
7860
    // processed further.
7870
    // processed further.
7861
    if (pressed && pp > 0)
7871
    if (pressed && (pp > 0 || !mUser.empty()))
7862
    {
7872
    {
7863
        if (!mPassword.empty())
7873
        if (!mPassword.empty())
7864
        {
7874
        {
7865
            if (mPassword[0] == 1)  // No or invalid password?
7875
            if (mPassword[0] == 1)  // No or invalid password?
7866
            {                       // Yes, then clear it and return
7876
            {                       // Yes, then clear it and return
Line 7868... Line 7878...
7868
                return false;
7878
                return false;
7869
            }
7879
            }
7870
 
7880
 
7871
            string pass;
7881
            string pass;
7872
 
7882
 
7873
            switch(pp)
7883
            if (!mUser.empty())
-
 
7884
                pass = TConfig::getUserPassword(mUser);
-
 
7885
 
-
 
7886
            if (pass.empty() && pp > 0)
7874
            {
7887
            {
-
 
7888
                switch(pp)
-
 
7889
                {
7875
                case 1: pass = TConfig::getPassword1(); break;
7890
                    case 1: pass = TConfig::getPassword1(); break;
7876
                case 2: pass = TConfig::getPassword2(); break;
7891
                    case 2: pass = TConfig::getPassword2(); break;
7877
                case 3: pass = TConfig::getPassword3(); break;
7892
                    case 3: pass = TConfig::getPassword3(); break;
7878
                case 4: pass = TConfig::getPassword4(); break;
7893
                    case 4: pass = TConfig::getPassword4(); break;
7879
                default:
7894
                    default:
7880
                    MSG_WARNING("Detected invalid password index " << pp);
7895
                        MSG_WARNING("Detected invalid password index " << pp);
7881
                    mPassword.clear();
7896
                        mPassword.clear();
7882
                    return false;
7897
                        return false;
-
 
7898
                }
7883
            }
7899
            }
7884
 
7900
 
7885
            if (pass != mPassword)  // Does the password not match?
7901
            if (pass != mPassword)  // Does the password not match?
7886
            {                       // Don't match then clear it and return
7902
            {                       // Don't match then clear it and return
7887
                MSG_PROTOCOL("User typed wrong password!");
7903
                MSG_PROTOCOL("User typed wrong password!");
Line 7892... Line 7908...
7892
            // The password match. We clear it and proceed.
7908
            // The password match. We clear it and proceed.
7893
            mPassword.clear();
7909
            mPassword.clear();
7894
        }
7910
        }
7895
        else if (gPageManager && gPageManager->getAskPassword())
7911
        else if (gPageManager && gPageManager->getAskPassword())
7896
        {
7912
        {
-
 
7913
            string msg;
-
 
7914
 
-
 
7915
            if (mUser.empty())
7897
            string msg = "Enter [" + intToString(pp) + "] password";
7916
                msg = "Enter [" + intToString(pp) + "] password";
-
 
7917
            else
-
 
7918
                msg = "Enter password for user " + mUser;
-
 
7919
 
7898
            mPassword.clear();
7920
            mPassword.clear();
7899
            gPageManager->getAskPassword()(mHandle, msg, "Password");
7921
            gPageManager->getAskPassword()(mHandle, msg, "Password");
7900
            return true;
7922
            return true;
7901
        }
7923
        }
7902
        else
7924
        else