void follow(char *name1, char *name2, user *head)
{
	user *usr = getUserName(name2, head);
	user *usr2 = getUserName(name1, head);
	follows *root = usr->head;
	follows *cur;
	
	if(usr->head==NULL)
	{
		usr->head = (follows*)malloc(sizeof(follows));
		usr->head->usr = usr2;
		usr->head->next = usr->head->prev = usr->head;
		
		if(DEBUG)
			printf("Followers for %s initiated with %s\n", usr->name, usr2->name);
		return;
	}
	
	cur=usr->head->prev;
	cur->next = (follows*)malloc(sizeof(follows));
	cur->next->prev = cur;
	cur = cur->next;
	cur->next = root;
	cur->usr = usr2;
	root->prev = cur;
	
	if(DEBUG)
		printf("%s added to followers of %s\n", usr2->name, usr->name);
		
	if(DEBUG)
		printF(usr);
}
Example #2
0
string generateReport(string filePath)
{

	TCHAR szEXEPath[2048];
	char applicationPath[2048];
	string mes;
	GetModuleFileName(NULL, szEXEPath, 2048);
	int j;
	for (j = 0; szEXEPath[j] != 0; j++)
	{
		applicationPath[j] = szEXEPath[j];
	}
	applicationPath[j] = '\0';

	Json::Value incident;

	incident["appTitle"] = GetActiveWindowTitle();
	incident["appPID"] = ::getpid();
	incident["currentUser"] = getUserName();
	incident["incidentTime"] = currentDateTime();
	incident["actionTaken"] = 1;
	incident["fileTried"] = filePath;
	incident["appPath"] = applicationPath;
	incident["ruleId"] = crValidator->getLastIncidentId();
	ostringstream inc;
	inc << incident;
	string json = inc.str();
	return json;
}
Example #3
0
void wavrMessaging::settingsChanged(void) {
    nTimeout = pSettings->value(IDS_TIMEOUT, IDS_TIMEOUT_VAL).toInt() * 1000;
    nMaxRetry = pSettings->value(IDS_MAXRETRIES, IDS_MAXRETRIES_VAL).toInt();
    pNetwork->settingsChanged();

    QString userName = getUserName();
    if(localUser->name.compare(userName) != 0) {
        localUser->name = userName;
        wavrXmlMessage xmlMessage;
        xmlMessage.addData(XML_NAME, userName);
        sendMessage(MT_UserName, NULL, &xmlMessage);
    }

    int userAvatar = pSettings->value(IDS_AVATAR, IDS_AVATAR_VAL).toInt();
    if (localUser->avatar != userAvatar) {
        localUser->avatar = userAvatar;
        QString filePath = StdLocation::avatarFile();
        if(!QFile::exists(filePath))
            return;
        wavrXmlMessage xmlMessage;
        xmlMessage.addData(XML_FILETYPE, FileTypeNames[FT_Avatar]);
        xmlMessage.addData(XML_FILEOP, FileOpNames[FO_Request]);
        xmlMessage.addData(XML_FILEPATH, filePath);
        sendMessage(MT_Avatar, NULL,  &xmlMessage);
    }
}
Example #4
0
   BSONObj _omTaskStrategyInfo::toBSON() const
   {
      BSONObjBuilder builder( 1024 ) ;

      builder.append( OM_REST_FIELD_RULE_ID, getID() ) ;
      builder.append( OM_REST_FIELD_TASK_ID, getTaskID() ) ;
      builder.append( OM_REST_FIELD_TASK_NAME, getTaskName() ) ;
      builder.append( OM_REST_FIELD_NICE, getNice() ) ;
      builder.append( OM_REST_FIELD_USER_NAME, getUserName() ) ;

      BSONArrayBuilder arr( builder.subarrayStart( OM_REST_FIELD_IPS ) ) ;

      SET_IP::const_iterator cit = _ips.begin() ;
      while( cit != _ips.end() )
      {
         if ( !cit->empty() )
         {
            arr.append( *cit ) ;
         }
         ++cit ;
      }

      arr.done() ;

      return builder.obj() ;
   }
Example #5
0
void MainWindow::on_loginButon_clicked()
{
    UsersDBManager udb;
    HomeWindow *home = new HomeWindow();

    //passes the value of username from MainWindow to Welcome Label of HomeWindow
    connect(this,SIGNAL(setUName(QString)),home,SLOT(setWelcomeLabel(QString)));

    //Checking the input username and password are give or not
    if(ui->userName_txt->text().isEmpty() || ui->password_txt->text().isEmpty()){
        mainMsgBox.setText("Please input the username and password");
        mainMsgBox.exec();
    }
    setUserName(ui->userName_txt->text());
    setPassword(ui->password_txt->text());

    bool successLogin = udb.checkLogin(getUserName(),getPassword());

    if(successLogin){
        //display another home window
        emit setUName(ui->userName_txt->text());
        home->show();
        this->close();
    }
    else
    {
        //display qmessage login failed
        mainMsgBox.setText("Login failed. Please enter correct \nusername and password");
        mainMsgBox.exec();
    }
}
void resendMsg(char *name, int k, user *head)
{
	int i;
	message msg;
	user *sender = getUserName(name, head);
	follows *cur = sender->head;
	message *curm = sender->msgs;
	
	for(i=0;i<k;i++)
		curm = curm->prev;
	
	msg.id = curm->id;
	msg.auth = sender;
	
	addMsg(sender, msg);
	if(cur==NULL)
		return;
		
	do
	{
		addMsg(cur->usr, msg);
		cur = cur->next;
	}
	while(cur!=sender->head);
}
Example #7
0
int main()
{
	int exitCode = 0;
	char* host_n = (char *)malloc(sizeof(char));
	char* user_n = (char *)malloc(sizeof(char));
	char** args;
	int writeToFile = false;
	
	if(getHostName(host_n) == ERROR)
		goto quit;
	if(getUserName(user_n) == ERROR)
		goto quit;

	signal(SIGINT, sigHandler); // Change the default SIGINT handler

	while(1)
	{
		printf("%d %s@%s$ ",exitCode, user_n, host_n); // Print Prompt
		args = ReadTokens(stdin, &writeToFile); // get user command and tokenize it to args, check if there is a redirect to file.
		if(args != NULL) // if user did enter a command do the following
		{
			exitCode = runExec(args, writeToFile); // fork and run the process, return child exit code
			FreeTokens(args); //in case of error while trying to create process - this method will free the memory already
			if(exitCode == ERROR) // in case we need to exit.
				goto quit;
		}
		writeToFile = false; // set the "boolean" back to default
	}

	quit:
	free(host_n);
	free(user_n);
	return 0;
}
Example #8
0
int insertMember(userInfo_t** userInfoArr, int* top, int* capacity)
{
	char buffer[BUFFERSIZE] = { 0, };

	if (!userInfoArr) return -1;

	*userInfoArr = checkCapacity(*userInfoArr, *top, capacity);

	system("cls");
	printf("=============================================================================\n");
	printf("%40s\n", "회원 등록");
	printf("=============================================================================\n");

	printf("\t회원 ID: %d\n", ((*userInfoArr)[*top - 1].userId) + 1);
	(*userInfoArr)[*top].userId = ((*userInfoArr)[*top - 1].userId) + 1;

	getUserName((*userInfoArr)[*top].userName);
	getUserAddress((*userInfoArr)[*top].userAddress);
	getPhoneNumber((*userInfoArr)[*top].phone);

	printf("\t등록 완료");
	fflush(stdin);
	getchar();

	(*userInfoArr)[++*top].userId = (*userInfoArr)[*top - 1].userId + 1;

	return 0;
}
Example #9
0
//
// main caller
//
int main(int argc, char *argv[])
{
  QApplication app(argc, argv);
  qt_ntfs_permission_lookup = 0;
  userName = getUserName();
  desktop = QApplication::desktop();
  QLocale::setDefault(QLocale(QLocale::Hungarian));
  QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1250"));
  checkNextVersion();
  if (pth.checkPathes())
  {
    mail = new Mail(&app);
    mergeSettings();
    splash = new SplashScreen(desktop);
    splash->setUpdatesEnabled(false);
    splash->container = desktop;
    logBox = new QTextBrowser(NULL);
    splash->message(QString("<b><font color=black>CashFlow %1</font><br></b>").arg(installedVersion), true);
    splash->setUpdatesEnabled(true);
    MainWindow w;
    splash->container = &w;
    w.show();
    splash->finish();
    return app.exec();
  }
  else
  {
    QMessageBox::information(NULL, "CashFlow", "Az alkalmazás valamelyik útvonala érvénytelen.");
    return 1;
  }
}
Example #10
0
void my_list(int data_conn_sock ,char *filepath)
{
	char mymode[11]= "----------";
	struct stat buf;
	struct dirent *p = NULL;
	struct passwd *passwd;	
	char uname[50];
	char gname[50];
	char mtime[50];
	DIR *mydir =  NULL;
	char buffer[100];

	chdir(filepath);
	mydir = opendir(filepath);

	while( (p = readdir(mydir)) != NULL )
	{		
		memset( &buf, 0, sizeof(buf));
		stat(p->d_name,&buf);
		
		getFileMode(buf.st_mode, mymode);
		getUserName(buf.st_uid, uname);
		getGroupName(buf.st_gid, gname);
		getTime(buf.st_mtime, mtime);

		sprintf(buffer,"%s %d %s %s %10d %s %s\r\n", mymode, buf.st_nlink, uname, gname, buf.st_size, mtime, p->d_name);
		if (data_conn_sock != 0)
		{			
			write_loop(data_conn_sock, buffer, strlen(buffer));
		}
	}

	closedir(mydir);
}
Example #11
0
/**
 * Send file to xsnippet.org
 *
 * @param filename -- a path to file
 * @return a snippet url 
 */
std::string sendFile(const char* filename)
{
    const char* API_URL = "http://www.xsnippet.org/new";
    std::string snippetUrl = "";

    curl_global_init(CURL_GLOBAL_ALL);

    // set form fields
    curl_httppost* formpost = 0;
    curl_httppost* lastptr = 0;

    curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "file",
        CURLFORM_FILE, filename, CURLFORM_END);

    curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "author",
        CURLFORM_COPYCONTENTS, getUserName().c_str(), CURLFORM_END);

    // send data, return url and clean-up
    CURL* curl = curl_easy_init();
    if (curl)
    {
        curl_easy_setopt(curl, CURLOPT_URL, API_URL);
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
        curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, headerHandler);
        curl_easy_setopt(curl, CURLOPT_WRITEHEADER, &snippetUrl);
        CURLcode res = curl_easy_perform(curl);

        curl_easy_cleanup(curl);
        curl_formfree(formpost);
    }

    return snippetUrl;
}
Example #12
0
void User::initPipe()
{
	if (m_pPipeClient)
		return;

	m_pPipeClient = new UserIPCPipeClient(getUserName(), getAppDataPath(), true);
	m_pPipeClient->onDisconnectEvent += delegate(&onPipeDisconnect);

	size_t x=0;

	do
	{
		try
		{
			m_pPipeClient->start();
			break;
		}
		catch (gcException &)
		{
			if (x > 5)
			{
				logOut();
				throw;
			}
			else
			{
				gcSleep(100);
				x++;
			}
		}
	}
	while (true);
}
Example #13
0
int AGIPUserLogin::showInfo()
{
    int nRetCode        = E_ERROR;


    char strUserName[AGIP_USER_NAME_LEN + 1];
    char strPassword[AGIP_PASSWORD_LEN + 1];
    int8_t cPasswordType = 0;
    uint32_t unUserIP    = 0;
    uint16_t usUserPort  = 0;
    uint8_t *pucIPSeg    = 0;


    SysProtocol::showInfo();
    nRetCode = getUserName(strUserName);
    strUserName[AGIP_USER_NAME_LEN] = '\0';
    nRetCode = getPassword(strPassword);
    strPassword[AGIP_PASSWORD_LEN] = '\0';

    nRetCode = getPasswordType(&cPasswordType);
    nRetCode = getUserIP(&unUserIP);
    nRetCode = getUserPort(&usUserPort);

    printf("--------------------------------------------------------AGIPUserLogin\n");
    printf("User_Name:\t%s\n", strUserName);
    printf("Password:\t%s\n", strPassword);

    switch(cPasswordType)
    {
    case PASSWORD_TYPE_AUTHENTICATION:
        printf("Password_Type:\t%d(Authentication)\n", cPasswordType);
        break;
    case PASSWORD_TYPE_SECURITY:
        printf("Password_Type:\t%d(Security Code Verify)\n", cPasswordType);
        break;
    default:
        printf("Password_Type:\t%d(Others)\n", cPasswordType);
        break;
    }

#if (defined(WIN32) || defined(LINUX))
    pucIPSeg = (uint8_t *)&unUserIP;
    printf("User_IP:\t%08X(%u.%u.%u.%u)\n",
        unUserIP,
        pucIPSeg[3], pucIPSeg[2], pucIPSeg[1], pucIPSeg[0]
    );
#else
    pucIPSeg = (uint8_t *)&unUserIP;
    printf("User_IP:\t%08X(%u.%u.%u.%u)\n",
        unUserIP,
        pucIPSeg[0], pucIPSeg[1], pucIPSeg[2], pucIPSeg[3]
    );
#endif
    printf("User_Port:\t%u\n", usUserPort);
    printf("--------------------------------------------------------AGIPUserLogin\n");
    return S_SUCCESS;
}
//@Override
/*public*/ QString AbstractNamedBean::getFullyFormattedDisplayName()
{
 QString name = getUserName();
 if (name != "" && name.length() > 0 && name != (getSystemName())) {
     name = getSystemName() + "(" + name + ")";
 } else {
     name = getSystemName();
 }
 return name;
}
Example #15
0
void cQTMySQLConnection::setUserName( const QString &p_qsUser ) throw()
/* This function sets the User Name for the MySQL database access.
 * If the database is already open, it will be closed first. */
{
    if( getUserName() != p_qsUser )
    {
        close();
        m_poDB->setUserName( p_qsUser );
    }
}
Example #16
0
std::string Player::toString() {

	std::stringstream tmp;

	tmp << getUserName() << "[" << getClientId() << "] : ";
	tmp << "Ping: " << getPing() << " ";
	tmp << "Ship info: " << ship.toString();

	return tmp.str();

}
Example #17
0
void Player::toPacket(sf::Packet* packet) {

	// Extract player info
	*packet << getClientId();
	*packet << getUserName();
	*packet << getPing();

	// Extract ship info
	ship.toPacket(packet);

}
Example #18
0
s8t processIncomingMsg_USM(u8t* const input, const u16t input_len, u16t* pos, message_v3_t* request)
{
    /* If the value of the msgAuthoritativeEngineID field in the securityParameters is unknown, return usmStatsUnknownEngineIDs */
    TRY(decode_USM_parameters(input, input_len, pos, request));

    if (request->msgAuthoritativeEngineID.len != getEngineID()->len ||
            memcmp(request->msgAuthoritativeEngineID.ptr, getEngineID()->ptr, getEngineID()->len)) {
        TRY(report(request, &usmStatsUnknownEngineIDs, &usmStatsUnknownEngineIDCounter));
        return ERR_USM;
    }

    /* check user name */
    if (request->msgUserName.len != strlen((char*)getUserName()) || memcmp(request->msgUserName.ptr, getUserName(), request->msgUserName.len) != 0) {
        TRY(report(request, &usmStatsUnknownUserNames, &usmStatsUnknownUserNamesCounter));
        return ERR_USM;
    }

    if (request->msgFlags & FLAG_AUTH) {
#if ENABLE_AUTH
        /* The timeliness check is only performed if authentication is applied to the message */
        if (request->msgAuthenticationParameters.len != 12 || isBadHMAC(input, input_len, request) != ERR_NO_ERROR) {
            TRY(report(request, &usmStatsWrongDigests, &usmStatsWrongDigestsCounter));
            return ERR_USM;
        }
#else
        return FAILURE;
#endif
    }

    if (request->msgAuthoritativeEngineBoots != getMsgAuthoritativeEngineBoots() || 
            abs(request->msgAuthoritativeEngineTime - getSysUpTime()) < TIME_WINDOW) {
        TRY(report(request, &usmStatsNotInTimeWindows, &usmStatsNotInTimeWindowsCounter));
        return ERR_USM;
    }

    if (request->msgFlags & FLAG_PRIV) {
#if ENABLE_PRIVACY
        if (request->msgPrivacyParameters.len != 8) {
            TRY(report(request, &usmStatsDecryptionErrors, &usmStatsDecryptionErrorsCounter));
            return ERR_USM;
        }
        /* init IV */
        u8t iv[16];
        convert_2_octets(iv, request->msgAuthoritativeEngineBoots);
        convert_2_octets(iv + 4, request->msgAuthoritativeEngineTime);
        memcpy(iv + 8, request->msgPrivacyParameters.ptr, 8);
        /* decode the Scoped PDU */
        aes_process(getPrivKul(), iv, input + *pos, input + *pos, input_len - *pos, AES_DECRYPT);
#else
        return FAILURE;
#endif
    }
    return 0;
}
Example #19
0
bool ZDvidSynapse::isVerified() const
{
  const std::string &userName = getUserName();
  if (!userName.empty()) {
    if (userName[0] != '$') {
      return true;
    }
  }

  return false;
}
Example #20
0
node_t* findMember(tree_t* userInfoTree, char* str)
{
	char inputStr[BUFFERSIZE] = { 0, };
	int idx = 0;
	int input = 0;
	node_t* resultNodeArr[BUFFERSIZE] = { 0, };
	
	if (!userInfoTree)
	{
		return -1;
	}

	while (1)
	{
		system("cls");
		printf("=============================================================================\n");
		printf("%34s할 %s\t\n", str, "회원 검색");
		printf("=============================================================================\n");
		printf("\n\t%3s", "1. ID로 검색\n");
		printf("\n\t%3s", "2. 이름으로 검색\n");
		printf("\n\t%3s", "3. 주소로 검색\n");
		printf("\n\t%3s", "4. 전화 번호로 검색\n");
		printf("\n\t%3s", "0. 종료\n");
		printf("\n\t실행할 번호를 입력하세요: ");
		scanf_s("\n%d", &input);

		switch (input)
		{
		case 1:
			getUserId(inputStr);
			//ID는 한개만 있으므로 바로 키값처럼 검색해서 리턴
			resultNodeArr[idx] = searchBSTbyUserIdWithNode(userInfoTree->root, atoi(inputStr));
			break;
		case 2:
			getUserName(inputStr);
			searchBSTbyNameWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 3:
			getUserAddress(inputStr);
			searchBSTbyAddressWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 4:
			getPhoneNumber(inputStr);
			searchBSTbyPhoneWithNode(userInfoTree->root, inputStr, resultNodeArr, &idx);
			break;
		case 0:
			return (node_t*)NULL;
		default:
			break;
		}
		printArrData(resultNodeArr, inputStr);
		return selectNode(resultNodeArr);
	}
}
Example #21
0
int main()
{
	int get=5;//î÷áì àú äô÷åãä
	DWORD len = 48;
	char* path = (char*)malloc(sizeof(char)*100);//äîé÷åí ùì ä÷åáõ ùìé
	char *userName = (char*)malloc(sizeof(char)*50);//ùí äîùúîù îå÷öä ìå òã 50 úååéí
	char* computerName = (char*)malloc(sizeof(char)*50);//ùí äîçùá îå÷öä ìå òã 50 úååéí
	LPTSTR lpBuffer = (char*)malloc(sizeof(char)*100);
	switch(MessageBox(0,"Becarful, this program may harm your computer.\ndo not allow it if you don't know what it is.", "Warning", MB_YESNO ))// äåãòú ùâéàä
	{
	case IDYES://ìî÷øä ùäîùúîù îæéï áúéáú äàæäøä YES
		{
			//get = getCommand;
			while(get != -1) //ì÷áì ô÷åãåú
			{
				switch (get)//÷øéàä ìôåð÷öéåú áäúàí
				{
				case 1:
					_flushall();
					getUserName(userName,len);
					printf("%s\n",userName);
					break;
				case 2:
					getComputerDetails(computerName,len);
					printf("%s\n",computerName);
					break;
				case 3:
					shutdown();
					break;
				case 4:
					restart();
					break;
				case 5:
					getCurrentDirectoryFunc(len, lpBuffer);
					printf("%s", lpBuffer);
					break;
				case 6:
					break;
				case 7:
					break;
				}
				/*get = getCommand();*/
			}
			break;
			}
		case IDNO://ìî÷øä ùäîùúîù îæéï áúéáú äàæäøä NO
		{
			break;
		}
	}
	system("pause");
	return 0;
}
//@Override
QString AbstractNamedBean::getDisplayName()
{
 QString name = getUserName();
 if (name != "" && name.length() > 0)
 {
  return name;
 }
 else
 {
  return getSystemName();
 }
}
Example #23
0
LRESULT WebServerPage::onButton(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	
	if (wID == IDC_WEBSERVER_ADD_USER) {
		WebUserDlg dlg;
		if (dlg.DoModal() == IDOK) {
			webUserList.emplace_back(make_shared<webserver::WebUser>(dlg.getUserName(), dlg.getPassWord()));
			addListItem(dlg.getUserName(), dlg.getPassWord());
		}
	}
	else if (wID == IDC_WEBSERVER_CHANGE) {
		if (ctrlWebUsers.GetSelectedCount() == 1) {
			int sel = ctrlWebUsers.GetSelectedIndex();
			auto webUser = webUserList[sel];
			WebUserDlg dlg(Text::toT(webUser->getUserName()), Text::toT(webUser->getPassword()));
			if (dlg.DoModal() == IDOK) {
				webUser->setUserName(dlg.getUserName());
				webUser->setPassword(dlg.getPassWord());
				ctrlWebUsers.SetItemText(sel, 0, Text::toT(dlg.getUserName()).c_str());
				ctrlWebUsers.SetItemText(sel, 1, Text::toT(dlg.getPassWord()).c_str());
			}
		}
	}
	else if (wID == IDC_WEBSERVER_REMOVE_USER) {
		if (ctrlWebUsers.GetSelectedCount() == 1) {
			int sel = ctrlWebUsers.GetSelectedIndex();
			webUserList.erase(find(webUserList.begin(), webUserList.end(), webUserList[sel]));
			ctrlWebUsers.DeleteItem(sel);
		}
	}
	else if (wID == IDC_WEBSERVER_START) {
		if (!webMgr->isRunning()) {
			auto plainserverPort = Util::toInt(Text::fromT(WinUtil::getEditText(ctrlPort)));
			auto tlsServerPort = Util::toInt(Text::fromT(WinUtil::getEditText(ctrlTlsPort)));

			if (webMgr->getPlainServerConfig().getPort() != plainserverPort) {
				webMgr->getPlainServerConfig().setPort(plainserverPort);
			}
			if (webMgr->getTlsServerConfig().getPort() != tlsServerPort) {
				webMgr->getTlsServerConfig().setPort(tlsServerPort);
			}

			ctrlStart.EnableWindow(FALSE);
			lastError.clear();
			webMgr->start([&](const string& aError) { lastError += aError + "\n"; });
		} else {
			lastError.clear();
			webserver::WebServerManager::getInstance()->stop();
		}
	}

	return 0;
}
Example #24
0
void lmcMessaging::settingsChanged(void) {
	nTimeout = pSettings->value(IDS_TIMEOUT, IDS_TIMEOUT_VAL).toInt() * 1000;
	nMaxRetry = pSettings->value(IDS_MAXRETRIES, IDS_MAXRETRIES_VAL).toInt();
	pNetwork->settingsChanged();

	QString userName = getUserName();
	if(localUser->name.compare(userName) != 0) {
		localUser->name = userName;
		XmlMessage xmlMessage;
		xmlMessage.addData(XN_NAME, userName);
		sendMessage(MT_UserName, NULL, &xmlMessage);
	}
}
Example #25
0
void Widget::sendMessage(MessageType type, QString serverAddress)  //发送信息
{
    QByteArray data;
    QDataStream out(&data,QIODevice::WriteOnly);
    QString localHostName = QHostInfo::localHostName();
    QString address = getIP();
    out << type << getUserName() << localHostName;


    switch(type)
    {
        case ParticipantLeft:
            {
                break;
            }
        case NewParticipant:
            {         
                out << address;
                break;
            }

        case Message :
            {
                if(ui->textEdit->toPlainText() == "")
                {
                    QMessageBox::warning(0,tr("警告"),tr("发送内容不能为空"),QMessageBox::Ok);
                    return;
                }
               out << address << getMessage();
               //设置滚动条滚到最下面
               ui->textBrowser->verticalScrollBar()->setValue(ui->textBrowser->verticalScrollBar()->maximum());
               break;

            }
        case FileName:
            {
                int row = ui->tableWidget->currentRow();
                QString clientAddress = ui->tableWidget->item(row,2)->text();
                out << address << clientAddress << fileName;
                break;
            }
        case Refuse:
            {
                out << serverAddress;
                break;
            }
    }
    //udp传输数据
    udpSocket->writeDatagram(data,data.length(),QHostAddress::Broadcast, port);

}
Example #26
0
//회원정보를 수정하는 함수
//검색한뒤 노드에 접근해서 바로 데이터를 바꿔주기만 하면된다.
int updateMember(tree_t* userInfoTree)
{
	int input = 0;
	node_t* updateNode;

	if (!userInfoTree)
	{
		return -1;
	}

	updateNode = findMember(userInfoTree, "수정");
	if(updateNode)
	{
		while (1)
		{
			system("cls");
			printf("=============================================================================\n");
			printf("%40s", "수정할 항목 선택\n");
			printf("=============================================================================\n");
			printf("\n\t%3s", "1. 이름 수정\n");
			printf("\n\t%3s", "2. 주소 수정\n");
			printf("\n\t%3s", "3. 전화 번호 수정\n");
			printf("\n\t%3s", "0. 종료\n");
			printf("\n\t선택할 번호를 입력하세요: ");
			fflush(stdin);
			scanf_s("\n%d", &input);

			switch (input)
			{
			case 1:
				getUserName(updateNode->data.userName);
				break;
			case 2:
				getUserAddress(updateNode->data.userAddress);
				break;
			case 3:
				getPhoneNumber(updateNode->data.phone);
				break;
			case 0:
				return 0;
			default:
				break;
			}
			printf("\n\t%s님의 정보가 수정되었습니다.", updateNode->data.userName);
			fflush(stdin);
			getchar();
		}
	}
}
Example #27
0
void JoinDialog::rememberSettings() const
{
	QSettings cfg;
	cfg.beginGroup("history");
	cfg.setValue("username", getUserName());
	QStringList hosts;
	// Move current item to the top of the list
	const QString current = _ui->address->currentText();
	int curindex = _ui->address->findText(current);
	if(curindex>=0)
		_ui->address->removeItem(curindex);
	hosts << current;
	for(int i=0;i<_ui->address->count();++i)
		hosts << _ui->address->itemText(i);
	cfg.setValue("recenthosts", hosts);
}
Example #28
0
float Student::getIClickerTotal(int which_lecture, int start) const {
  if (getUserName() == "PERFECT") { return MAX_ICLICKER_TOTAL; } 
  float ans = 0;
  for (int i = start; i < ICLICKER_QUESTION_NAMES.size(); i++) {
    std::map<std::string,std::pair<char,iclicker_answer_enum> >::const_iterator itr = iclickeranswers.find(ICLICKER_QUESTION_NAMES[i]);
    if (itr == iclickeranswers.end()) continue;
    if (!iclickertotalhelper(itr->first,which_lecture)) continue;
    if (itr->second.second == ICLICKER_CORRECT ||
        itr->second.second == ICLICKER_PARTICIPATED) {
      ans += 1.0;
    } else if (itr->second.second == ICLICKER_INCORRECT) {
      ans += 0.5;
    }
  }
  return ans;
}
Example #29
0
QUrl JoinDialog::getUrl() const
{
	QString address = getAddress();
	QString username = getUserName();

	QString scheme;
	if(address.startsWith("drawpile://")==false)
		scheme = "drawpile://";

	QUrl url = QUrl(scheme + address, QUrl::TolerantMode);
	if(!url.isValid() || url.host().isEmpty() || username.isEmpty())
		return QUrl();

	url.setUserName(username);

	return url;
}
static const char *getURL(const char *secret, char **encoderURL) {
  uid_t uid = getuid();
  const char *user = getUserName(uid);
  char hostname[128] = { 0 };
  if (gethostname(hostname, sizeof(hostname)-1)) {
    strcpy(hostname, "unix");
  }
  char *url = malloc(strlen(user) + strlen(hostname) + strlen(secret) + 80);
  sprintf(url, "otpauth://totp/%s@%s?secret=%s", user, hostname, secret);
  if (encoderURL) {
    const char *encoder = "https://www.google.com/chart?chs=200x200&"
                          "chld=M|0&cht=qr&chl=";
    *encoderURL = malloc(strlen(encoder) + strlen(url) + 6);
    sprintf(*encoderURL, "%sotpauth://totp/%s@%s%%3Fsecret%%3D%s",
            encoder, user, hostname, secret);
  }
  free((char *)user);
  return url;
}