Ejemplo n.º 1
0
/************
 *
 *功能:主界面
 * 初始实例化所有的子窗口对象,设置字符编码,检测读取版本号,
 *更改或创建wifi管理工具wpa_supplicant的配置文件wpa_supplicant.conf,启动wifi后台管理服务,
 *设置主界面样式和初始化布局,多个子窗口间通信的信号和槽的初始化连接操作。
 *
 *
 **/
mainview::mainview(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::mainview)
{
    /****set Shortcut Keys*****/
    QShortcut  *m_ALT_down_Accel= new QShortcut(QKeySequence(tr("Ctrl+Shift+Alt+Y")), this);

    this->login     = NULL;
    this->netconfig = NULL;
    this->wifi      = NULL;
    ui->setupUi(this);
    logo_x=QApplication::desktop()->width()/2-100;
    logo_y=50;
    open = false;

    //this->setStyleSheet("background-image:url(:/images/terminal-bg.jpg);");
    /*********Set  Unicode *********/
    QTextCodec *codec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForTr(codec);
    QTextCodec::setCodecForLocale(codec);
    QTextCodec::setCodecForCStrings(codec);

    spicy_thread_id.clear();

    QFile file_version( "./version.txt" );
    if ( file_version.open(QIODevice::ReadOnly | QIODevice::Text) ) {
        QByteArray  line = file_version.readLine();
        QString mg = line;
        file_version.close();
        QStringList md = mg.split("\n");
        version = "ver "+md.at(0);
    }
    else
    {
        version = "ver 3.0.1";
    }

        QFile  file_eth("./wpa_supplicant.conf");
            if (!file_eth.open(QIODevice::ReadOnly)&&
                file_eth.open(QIODevice::WriteOnly|QIODevice::Text)) {
                QTextStream out(&file_eth);
                out<<"ctrl_interface=/var/run/wpa_supplicant\nctrl_interface_group=0\nap_scan=1\n"<<endl;
                out.flush();

                file_eth.close();
            }
            else
                file_eth.close();

    //start wpa_supplicant  service
    QProcess::execute("ifconfig wlan0 up");
    startthread("wpa_supplicant -Dwext -iwlan0 -c ./wpa_supplicant.conf "); 
    //startthread("dhclient wlan0");
    /*********Set Button Style************/
    ui->pushButton->setStyleSheet("background-color:transparent");
    //ui->pushButton->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton->setText("");
    ui->pushButton->setFlat(true);
    ui->pushButton->setFocusPolicy(Qt::NoFocus);
    ui->pushButton_1->setStyleSheet("QPushButton{text-align:left;}");
    ui->pushButton_1->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton_1->setStyleSheet("background-color:transparent");
    ui->pushButton_1->setText("");
    ui->pushButton_1->setFlat(true);
    ui->pushButton_1->setFocusPolicy(Qt::NoFocus);
    //ui->pushButton_2->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton_2->setStyleSheet("background-color:transparent");
    ui->pushButton_2->setText("");
    ui->pushButton_2->setFlat(true);
    ui->pushButton_2->setFocusPolicy(Qt::NoFocus);
    //ui->pushButton_3->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton_3->setStyleSheet("background-color:transparent");
    ui->pushButton_3->setText("");
    ui->pushButton_3->setFlat(true);
    ui->pushButton_3->setFocusPolicy(Qt::NoFocus);
    //ui->pushButton_4->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton_4->setStyleSheet("background-color:transparent");
    ui->pushButton_4->setText("");
    ui->pushButton_4->setFlat(true);
    ui->pushButton_4->setFocusPolicy(Qt::NoFocus);
    //ui->pushButton_5->setStyleSheet("border: 0px");//消除边框,取消点击效果
    ui->pushButton_5->setStyleSheet("background-color:transparent");
    ui->pushButton_5->setText("");
    ui->pushButton_5->setFlat(true);
    ui->pushButton_5->setFocusPolicy(Qt::NoFocus);
    //ui->pushButton_5->setVisible(false);
#if  1
    this->login = new  Login();
    this->netconfig = new NetworkConfig();
    this->wifi = new  Wifi();
    //this->termigrate = new  Termigrate();

    http = new  SocketService();
    changepasswd= new  ChangePasswd();
    hostlist = new  CreateVmlist();
    
    ui->widgetstack->addWidget(login);
    ui->widgetstack->addWidget(netconfig);
    ui->widgetstack->addWidget(changepasswd);
    ui->widgetstack->addWidget(wifi);
    ui->widgetstack->addWidget(hostlist);
    ui->widgetstack->resize(0,0);


    ui->widgetlist->setMovement(QListView::Static);
    ui->widgetlist->setFocusPolicy(Qt::NoFocus);
    ui->widgetlist->addItem("用户登录");
    ui->widgetlist->addItem("修改配置");
    ui->widgetlist->addItem("修改密码");
    ui->widgetlist->setSpacing(4);
    ui->widgetlist->setMouseTracking(true);
    ui->widgetlist->item(0)->setSizeHint(QSize(30,30));
    ui->widgetlist->item(1)->setSizeHint(QSize(30,30));
    ui->widgetlist->item(2)->setSizeHint(QSize(30,30));

    


    connect(this,SIGNAL(loadoperator(int)),this,SLOT(changeslots(int)));
    connect(ui->widgetlist,SIGNAL(currentRowChanged(int)),this,SLOT(deal_widgets(int)));
    connect(ui->widgetlist,SIGNAL(itemEntered(QListWidgetItem *)),this,SLOT(changeColor(QListWidgetItem *)));
    for(int i=0;i<ui->widgetlist->count();i++)
    {
        ui->widgetlist->item(i)->setBackground(QBrush(QColor(255,255,255)));
        ui->widgetlist->item(i)->setSelected(false);
    }


    /********Set  Function Key As following:reflush, wifi, help, shutdown, reboot**********/
    //get vmhostlist by  click  the  reflush  function
    setMouseTracking(true);
    ui->pushButton->setMouseTracking(true);
    ui->pushButton_1->setMouseTracking(true);
    ui->pushButton_2->setMouseTracking(true);
    ui->pushButton_3->setMouseTracking(true);
    ui->pushButton_4->setMouseTracking(true);
    ui->pushButton_5->setMouseTracking(true);
    connect(ui->pushButton,SIGNAL(clicked()),this->http,SLOT(gethostlist_slots()));
    connect(this->http,SIGNAL(signals_vmlist(QString)),this,SLOT(reflushlisttable(QString)));



    connect(ui->pushButton_1,SIGNAL(clicked()),this,SLOT(moreoperator()));
    connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(wifioperator()));
    connect(ui->pushButton_3,SIGNAL(clicked()),this,SLOT(helpoperator()));
    connect(ui->pushButton_4,SIGNAL(clicked()),this,SLOT(closecomputer()));
    connect(ui->pushButton_5,SIGNAL(clicked()),this,SLOT(rebootcomputer()));

    /*** this function is logining  when the login window whose login_signals had been sended by click the OK_button.**/
    connect(this->login,SIGNAL(signals_loginmsg(QString)),this->http,SLOT(login_slots(QString)));//send login information by httpsocket
    //connect(this->login,SIGNAL(signals_loginmsg(QString)),this->hostlist,SLOT(getuserinfo(QString)));//send login information 
    connect(this->http,SIGNAL(signals_loginview(int)),this,SLOT(emit_widgets(int)));
    connect(m_ALT_down_Accel, SIGNAL(activated()), this, SLOT(docreen()));

    /*** this is connect the signals with the networkconfigview and modify the password windows **/
    connect(this->netconfig,SIGNAL(signals_cdms(QString)),this->http,SLOT(registertocdms(QString)));
    connect(this->netconfig,SIGNAL(signals_modifycdms(QString)),this->http,SLOT(modifycdmsSlots(QString)));
    connect(this->changepasswd,SIGNAL(signals_modify(QString)),this->http,SLOT(updateUserinfo(QString)));
    connect(this->changepasswd,SIGNAL(docancel()),this->http,SLOT(gethostlist_slots()));

    /*** when click the OK_button that is the networkconfigview button,the thread will be create to runing shell command**/
    connect(this->netconfig,SIGNAL(signals_startthread(QString)),this,SLOT(startthread(QString)));


    /***it is registertocdms at first when the  programmer  running***/
    connect(this->http,SIGNAL(signals_register()),this->netconfig,SLOT(SendRegisterData()));
    /***if connect error,switch to netconfig view***/
    connect(this->http,SIGNAL(signals_connectError(int)),this,SLOT(emit_widgets(int)));
    /*** it's used to  start  the  spicy  protocol thread at the  SocketService class***/
    connect(this->http,SIGNAL(signals_startspicy(QString)),this,SLOT(startthread(QString)));
    //connect(this->http,SIGNAL(signals_tohostlistcheck(QString)),this->hostlist,SLOT(checkuserinfo(QString)));//check the userinfo is the same as  already logininfo

    /****there is  the  signals which serves for  vmhostlist contained  three vmhost most****/
    connect(this->hostlist,SIGNAL(signals_vm(QString)),this->http,SLOT(getconnectinfo_slots(QString)));
    connect(this->hostlist,SIGNAL(signals_connect(QString)),this->http,SLOT(isableconnectslots(QString)));
    connect(this->hostlist,SIGNAL(signals_start(QString)),this->http,SLOT(startvmslots(QString)));
    connect(this->hostlist,SIGNAL(signals_down(QString)),this->http,SLOT(shutdownvmslots(QString)));
    connect(this->hostlist,SIGNAL(signals_reboot(QString)),this->http,SLOT(rebootvmslots(QString)));

    /*******it's connected the  windows  with  the   choose  table on the  mainview  windows*******/
    connect(this,SIGNAL(signals_widgets(int)),ui->widgetstack,SLOT(setCurrentIndex(int)));
    /****it's used  to  execute  the  shell command int  the  function of  Wifi class****/
    connect(this->wifi,SIGNAL(signals_connect(QString)),this,SLOT(startthread(QString)));
    /****it's used to update  connected  wifiname on  the  mainview  background ********/
    connect(this->wifi,SIGNAL(signals_update()),this,SLOT(repaint()));
    connect(this->wifi,SIGNAL(siglogin(int)),this,SLOT(deal_widgets(int)));

    /******it's used  to  migrate  vitural machine ,that send oldip to tcp server for close it********/
    //connect(this->http,SIGNAL(signals_startmigrate(QString)),this->termigrate,SLOT(WriteIpToShm(QString)));
#endif
}
Ejemplo n.º 2
0
Archivo: spawn.c Proyecto: siefca/spawn
int main (int argc, char *argv[])
    {
    char *p;
    int x;
    
    initlocale ();
    
    if (!argv[1] || !(*argv[1])) { usage (argv[0]); exit (1); }
    else
    while ((x=getopt(argc, argv, "VBhvsxze:f:c:")) != EOF)
	{
		switch (x)
		    {
		    case 'V':
			    print_version ();
			    exit (0);
			    break;
		    case 'h':
			    usage (argv[0]);
			    exit (0);
			    break;
		    case 'v':
			    ST.verbose_mode = 1;
			    break;
		    case 's':
			    ST.verbose_mode = 1;
			    ST.vverbose_mode = 1;
			    break;
		    case 'c':
			    ST.count = preprocess_retries (optarg);
			    if (ST.count == -1) exit (1);
			    break;
		    case 'e':
			    ST.exit_code = preprocess_code (optarg);
			    if (ST.exit_code == -1) exit (1);
			    break;
		    case 'f':
			    ST.forktime = preprocess_time (optarg);
			    if (ST.forktime == -1) exit (1);
			    break;
		    case 'n':
			    ST.nohup = 1;
			    break;
		    case 'x':
			    ST.pscan = 1;
			    break;
		    case 'z':
			    ST.always_zero = 1;
			    break;
		    case 'B':
			    ST.buster = 1;
			    break;
		    default :
			    usage (argv[0]);
			    exit (0);
			    break;
		}

	}

    if (argv[optind] == NULL || argv[optind] == '\0')
	{
	usage (argv[0]);
	exit (0);
	}
	
    command_name[sizeof(command_name)-1] = '\0';
    strncpy (command_name, argv[optind], sizeof(command_name)-2);
    if ((p = strchr (command_name, ' '))) *p = '\0';
    command[sizeof(command)-1] = '\0';
    strncpy (command, argv[optind], sizeof(command)-2);

    if (ST.pscan) 
	VERB fprintf (stderr, _("spawn: CPR mode enabled\n"
			        "       exit code cannot be resolved due to alternate scanning method\n"));
    init_invokes ();
    init_signals ();
    invoke_here (command);
    signals_start ();

    return (0);
    }
Ejemplo n.º 3
0
void    CreateVmlist::emit_start_signals()
{
    emit   signals_start(ids[idvm]);

}