Example #1
0
//移出黑名单按钮触发事件
void middle7::del_black()
{
	QListWidgetItem *item = list->currentItem();//获取按钮点击的item
	QString temp = item->text();//保存item的值
//在数组中删除该用户
	for(int i=0;i<flag;i++)
	{
		if(user_temp[i] == temp)
		{
			for(int j=i;j<flag;j++)
			  user_temp[j] = user_temp[j+1];
		}
	}
	QListWidgetItem *item1 = new QListWidgetItem;//新建一个item
	list->removeItemWidget(item);//删除原item
	delete item;
	item1->setIcon(QIcon(":images/user.png"));
	item1->setText(temp);
	list->addItem(item1);

    QFile mypwdfile("/tmp/pwd");
	mypwdfile.open(QFile::ReadOnly);
	QTextStream myin(&mypwdfile);
	QString pwd = myin.readLine();
	mypwdfile.close();

    system("bash del-black.sh "+pwd.toLatin1() +" "+ temp.toLatin1());

}
Example #2
0
//删除按钮触发事件
void middle7::del_user()
{
	QListWidgetItem *item = list->currentItem();
	QString user = item->text();
    QFile mypwdfile("/tmp/pwd");
	mypwdfile.open(QFile::ReadOnly);
	QTextStream myin(&mypwdfile);
	QString pwd = myin.readLine();
	mypwdfile.close();
	QProcess *thread1 = new QProcess;
    thread1->start("bash del_user.sh "+pwd+" "+user);
	if(!thread1->waitForStarted())
	{
		qDebug()<<"failed start!";
	}

	while(true == thread1->waitForFinished());
	{
        qDebug()<<"hello";
		middle7::show_user();
	}
}
Example #3
0
//加入黑名单按钮触发事件
void middle7::add_black()
{
	QListWidgetItem *item = list->currentItem();
	QString temp = item->text();
	user_temp[flag] = temp;
	flag++;
	QListWidgetItem *item1 = new QListWidgetItem;
	list->removeItemWidget(item);
	delete item;
	item1->setIcon(QIcon(":images/userlock.png"));
	item1->setText(temp);
	list->addItem(item1);

    QFile mypwdfile("/tmp/pwd");
	mypwdfile.open(QFile::ReadOnly);
	QTextStream myin(&mypwdfile);
	QString pwd = myin.readLine();
	mypwdfile.close();

    system("bash add-black.sh "+pwd.toLatin1() +" "+ temp.toLatin1());

}
Example #4
0
int main(int argc, char *argv[])
{

int i = 0;

ifstream myin("test.dat");
ifstream prefin("pref.dat");
ofstream myout("out.js");

if(!myin) {
	cout << "cannot open the file \n";
	return 1;
}


while (!myin.eof()) {
	myin >> ptr_ga[i].name >> ptr_ga[i].value ;
//	cout << ptr_ga[i].name <<","<< ptr_ga[i].value <<"\n";

	i++;

}

myin.close();
if(!myout) {
	cout << "cannot open the file \n";
	return 1;
}

if (argc == 1) 
{
	
	char prefer [7];
	char prefname[50];
	char pref1[5];
	char pref2[7];
	char bool1[5];
	char bool2[6];

if(!prefin) {
	cout << "cannot open the file \n";
	return 1;
}


while (!prefin.eof()) {

	prefin >> prefer >> prefname ;
//	cout <<"This is "<< prefer << " and " << prefname << "\n";
	i++;



	strcpy(pref1, "pref");
	strcpy(pref2, "config");
	strcpy(bool1, "true");
	strcpy(bool2, "false");

	if (strcmp(prefer,pref1) ==0)
	{
//		cout << "inside the def pref \n";
		if (GetGlobal(prefname)!= NULL)
		{	if (( strcmp (GetGlobal(prefname), bool1) == 0)|| ( strcmp (GetGlobal(prefname), bool2)== 0) || (isnum (GetGlobal(prefname))))
		{	//cout << "the current value is " <<GetGlobal(prefname)<<"\n";
			myout<< "defaultPref(\"" << prefname << "\", " <<GetGlobal(prefname) <<");\n";
		}
			else 
			myout<< "defaultPref(\"" << prefname << "\", \"" <<GetGlobal(prefname) <<"\");\n";
		}
		else
			cout << prefname << " is not found \n";
	}
	
	else if (strcmp(prefer,pref2) ==0)
	{
//		cout << "inside the config \n";

		if (GetGlobal(prefname)!= NULL)
		{	if (( strcmp (GetGlobal(prefname), bool1) == 0)|| ( strcmp (GetGlobal(prefname), bool2) == 0) || (isnum (GetGlobal(prefname))))
		{//cout << "the value of isnum is " << isnum <<"\n";
		//cout << "the curretn value is "<<GetGlobal(prefname)<<"\n";
		myout<< "config(\"" << prefname << "\", " <<GetGlobal(prefname) <<");\n";
		}
		else 
			myout<< "config(\"" << prefname << "\", \"" <<GetGlobal(prefname) <<"\");\n";
		}
		else
			cout << prefname << " is not found \n";
	}



}

}