Exemplo n.º 1
0
/*****
 *  Function: when change password , this  Slot will be  Called by the  
 *  signals_modify  signals of  mainview class . 
 *
 *
 ******/
void    SocketService::updateUserinfo(const QString  &newpass)
{
    if(userpass.length() > 0)
    {

        std::string  paswd = "oldPassword="******"&newPassword="******"ChangePassword";	//ChangePassword
        std::string str20 = paswd+"&"+userpass;
        std::string  strmg="";
        //qDebug()<<str20.c_str();
        http->Post(str11,str20, strmg);
        qDebug()<<strmg.c_str();
        if(strmg.length() <= 0)
        {
            LOG("error:SocketService::updateUserinfo  ChangePassword not respondly.");
            return ;
        }
        cJSON   *json  = cJSON_Parse(strmg.data());
        if(json == NULL)
        {
            LOG("error:updateuserinfo:JSON Pare error!");
            emit  signals_httperror("updateuserinfo:JSON Pare error!");
            return;
        }
        cJSON   *json_result = cJSON_GetObjectItem(json,"result");
        QString   result = json_result->valuestring;
        qDebug() <<"Result:"<<result;
        if(result.compare("true") == 0)
        {
            ResetUserInfo();
            emit this->signals_loginview(0);
        }
        else
        {
            cJSON   *json_error = cJSON_GetObjectItem(json,"errorMsg");

            emit  signals_httperror(json_error->valuestring);

        }
        cJSON_Delete(json);
    }
    else
    {  
        ResetUserInfo();
        //emit  signals_httperror("Please to Login.");
        emit this->signals_loginview(0);

    }
}
Exemplo n.º 2
0
void    SocketService::rebootvmslots(const QString &vmid)//reboot  virtual machine
{
    std::string str1 = httphead+"Hello";
    std::string strmg = "";
    http->Post(str1, "", strmg);
    qDebug() << "regidter hello:"<<strmg.c_str();
    if(strmg.length() <= 0)
    {
        emit  this->signals_connectError(1);
        return;
    }
    if(userpass.length() <= 0)
    {
        ResetUserInfo();
        //emit  signals_httperror("Please to Login.");
        emit  signals_loginview(0);
        return ;
    }
    QString   params = "&hostId="+ vmid;
    std::string   hostid = params.toLocal8Bit().data();
    std::string   httpinfo =  httphead + "ForcedReboot";
    std::string   checkinfo = userpass + hostid; 
    std::string   strmsg = "";

    qDebug()<<"checkinfo:"<<checkinfo.c_str();
    http->Post(httpinfo, checkinfo, strmsg);
    // if(strmsg.length() <= 0)
    //{
    //sleep(500);
    //http->Post(httpinfo, checkinfo, strmsg);
    //}
    qDebug() << "closevm:"<<strmsg.c_str();
    JSParse(strmsg);

}
Exemplo n.º 3
0
void BlackListWindow::AddBlackListMember(const nim::UserNameCard & info)
{
	ui::ListContainerElement* black_item = (ui::ListContainerElement*)m_black_list->FindSubControl(nbase::UTF8ToUTF16(info.GetAccId()));
	if (black_item != NULL)
		return;
	black_item = dynamic_cast<ui::ListContainerElement*>(ui::GlobalManager::CreateBoxWithCache(L"black_list/black_list_item.xml"));
	black_item->SetUTF8Name(info.GetAccId());
	m_black_list->Add(black_item);
	ResetUserInfo(info);
	ui::Button* remove = static_cast<ui::Button*>(black_item->FindSubControl(L"confirm"));
	remove->SetUTF8DataID(info.GetAccId()); // 把用户帐号保存到按钮的m_sUserData中
	remove->AttachClick(nbase::Bind(&BlackListWindow::OnRemoveBtnClicked, this, std::placeholders::_1));
}
Exemplo n.º 4
0
/*****
 *  Function: to  get  the  virtual  pc  list. 
 *
 *  the  slot   will be  called by   the   signals_gethostlist  signal.
 *
 ******/
void    SocketService::gethostlist_slots()
{
    vmsinfors.clear();
    /*****check the  service  if  can  arrived*****/
    std::string str1 = httphead+"Hello";
    std::string strmg = "";
    http->Post(str1, "", strmg);
    //qDebug() << "regidter hello:"<<strmg.c_str();
    if(strmg.length() <= 0)
    {
        emit  this->signals_connectError(1);//if get  hostlist  failed  ,open the  networkconfig  window.
        return;
    }
    //QDateTime  time = QDateTime::currentDateTime();
    //QString  strtime = time.toString("MMddhhmmssddd");
    std::string str11 = httphead+"getHostList";//+strtime.toLocal8Bit().data();//"http://10.3.3.59/index.php?r=api/getHostList";	//getHostList
    std::string str20 = userpass;//"username=qsau_test_1&password=qsau_test_1";
    //check  username and  passwd if OK then  post
    if(userpass.length() > 0 && login_state == true)
    {
        strhostlist = "";
        http->Post(str11, str20, strhostlist);
        qDebug() <<"=============list:"<<strhostlist.c_str();
        if(strhostlist.length()<=0)
        {
            emit  signals_httperror("server not respond!");
            return;
        }
        cJSON   *json  = cJSON_Parse(strhostlist.data());
        cJSON   *json_result = cJSON_GetObjectItem(json,"result");
        if(json_result == NULL)
        {
            emit  signals_httperror("JSON Pare error!");
            return ;
        }
        QString   result = json_result->valuestring;
        //qDebug() <<"Result:"<<result;
        if(result.compare("true") == 0)
        {
           // emit    signals_tohostlistcheck(userpass.c_str());
            cJSON   *json_vmlist = cJSON_GetObjectItem(json,"params");
            if(json_vmlist == NULL)
            {
                return ;
            }
            cJSON   *json_array = cJSON_GetObjectItem(json_vmlist,"hosts");
            if(json_array == NULL)
            {
                return ;
            }
            int   array_size = cJSON_GetArraySize(json_array);

            QString   hostlist="",onevm="";
            for(int i=0;i < array_size;i++)
            {
                cJSON   *item = cJSON_GetArrayItem(json_array,i);
                //qDebug() <<i<<":"<< cJSON_Print(item);
                json_result = cJSON_GetObjectItem(item,"hostName");
                if(json_result != NULL)
                    result = json_result->valuestring;
                else
                    result = "unknown";
                //qDebug() <<result;
                hostlist += result + "\t";
                onevm += result + "\t";

                json_result = cJSON_GetObjectItem(item,"hostId");
                if(json_result != NULL)
                    result = json_result->valuestring;
                else
                    result = "unknown";
                //qDebug() <<result;
                hostlist += result + "\t";
                onevm += result + "\t";

                json_result = cJSON_GetObjectItem(item,"status");
                if(json_result != NULL)
                    result = json_result->valuestring;
                else
                    result = "unknown";
                //qDebug() <<result;
                hostlist += result + "\t";
                onevm += result + "\t";

                json_result = cJSON_GetObjectItem(item,"protocol");

                if(json_result != NULL)
                {
                    int  size = cJSON_GetArraySize(json_result);
                    for(int j=0;j < size;j++)
                    {
                        cJSON  *item_item = cJSON_GetArrayItem(json_result,j);
                        result = item_item->valuestring;
                        //qDebug() <<result;
                        if(result.length() > 0)
                        {
                            hostlist += result + "\t";
                            onevm += result + "\t";
                        }
                        else
                        {
                            hostlist += "unknown\t";
                            onevm += "unknown\t";


                        }
                    }
                }
                else
                {
                    hostlist += "unknown\t";
                    onevm += "unknown\t";

                }

                json_result = cJSON_GetObjectItem(item,"type");
                if(json_result != NULL)
                {//qDebug() <<json_result->valueint;
                    hostlist += QString::number(json_result->valueint) + "\n";
                    onevm += QString::number(json_result->valueint);
                }
                else
                {
                    hostlist += QString::number(-1) + "\n";
                    onevm += QString::number(-1);

                }
                vmsinfors.push_back(onevm);
                onevm="";
            }

            emit  this->signals_vmlist(hostlist); 

        }
        else
        {
            cJSON   *json_error = cJSON_GetObjectItem(json,"errorMsg");
            emit  signals_httperror(json_error->valuestring);

        }


        cJSON_Delete(json);
    }else
    {
        ResetUserInfo();
        //emit  signals_httperror("Please to Login.");
        emit  signals_loginview(0);
    }


}
Exemplo n.º 5
0
/*****
 *  Function: check  login  information  if  effect  for  server  terminal. 
 *
 *  this  slot  will be  called  when  the  signals_loginmsg  signal of  Login  class   send   out.
 *
 *
 ******/
void    SocketService::login_slots(const QString &userpasswd)
{
    /*****check the  service  if  can  arrived*****/
    std::string str1 = httphead+"Hello";
    std::string strmg = "";
    http->Post(str1, "", strmg);
    //qDebug() << "regidter hello:"<<strmg.c_str();
    if(strmg.length() <= 0)
    {
        emit  this->signals_connectError(1);
        return;
    }

    ResetUserInfo();
    qDebug() << userpasswd;
    QStringList  usepasswd = userpasswd.split("\n");
    user = usepasswd.at(0).toLocal8Bit().data();
    passwd = usepasswd.at(1).toLocal8Bit().data();

    userpass = "******"+user+"&password="******"*/;



    qDebug()<<"socketservice:"<<user.c_str()<<":"<<passwd.c_str();
    std::string str10 = httphead+"login";
    //str10 = "http://10.3.3.59/index.php?r=api/login"; //login
    std::string str20 = userpass;//"username=qsau_test_1&password=qsau_test_1";

    qDebug()<<userpass.c_str();
    strloginCheck="";
    http->Post(str10, str20, strloginCheck);
    qDebug() << strloginCheck.c_str();
    if(strloginCheck.length() <= 0)
    {
        LOG("error:server no  respond when login_slots!");
        emit  signals_httperror("server no  respond when login!");
        return;
    }
    cJSON   *json  = cJSON_Parse(strloginCheck.data());
    if(json == NULL)
    {
        LOG("error:login:JSON Pare error!");
        emit  signals_httperror("login:JSON Pare error!");
        return;
    }
    cJSON   *json_result = cJSON_GetObjectItem(json,"result");
    if(json_result == NULL)
    {
        emit  signals_httperror("JSON Pare error!");
        return ;
    }
    QString   result = json_result->valuestring;
    //qDebug() <<"Result:"<<result;
    if(result.compare("true") == 0)
    {
        login_state = true;
        emit   this->signals_gethostlist();
    }
    else
    {
        cJSON   *json_error = cJSON_GetObjectItem(json,"errorMsg");

        emit  signals_httperror(json_error->valuestring);
        emit  signals_loginview(0);
    }
    cJSON_Delete(json);
}
Exemplo n.º 6
0
void BlackListWindow::OnUserInfoChange(const std::list<nim::UserNameCard>& uinfos)
{
	for (const auto &info : uinfos)
		ResetUserInfo(info);
}