Exemplo n.º 1
0
int search(char *movie, char *info){
   int res=0;
   char aux[MAX_LEN];
   char *include;
   FILE *pfile;
   pfile=fopen("movie.txt","r");
   if(pfile==NULL){
      res=-1;
   }else{
      do{
         fgets(aux,MAX_LEN,pfile);
         deleteCharacter(aux);
         include=strstr(aux,movie);
         if(include!=NULL){
            strcpy(info,aux);
            res=1;
         }
      }while(!feof(pfile)  && res!=1);

      if(res==0){

         strcpy(info,"No results found");
      }
     
      fclose(pfile);
   }
   return res;
}
Exemplo n.º 2
0
 void TextField::backspace()
 {
     if(cursor_ > 0){
         deleteCharacter();
         repaint();
     }
 }
Exemplo n.º 3
0
void trimNs(char* sequence, char* quality)
{
    // Delete leading N's.
    while(strlen(sequence) >= 1 && 
            (sequence[0] == 'N' || sequence[0] == 'n'))
    {
        deleteCharacter(sequence, 0);
        deleteCharacter(quality, 0);
    }
    
    // Delete trailing N's.
    while(strlen(sequence) >= 1 && 
            (sequence[strlen(sequence) - 1] == 'N' || sequence[strlen(sequence) - 1] == 'n'))
    {
        deleteCharacter(sequence, strlen(sequence) - 1);
        deleteCharacter(quality, strlen(quality) - 1);
    }    
}
Exemplo n.º 4
0
void UrlBar::handleKeyReleaseEvent(const XKeyReleasedEvent& event)
{
    char normalKey;
    KeySym specialKey;

    XLookupString(const_cast<XKeyEvent*>(&event), &normalKey, sizeof(char), &specialKey, 0);

    switch (specialKey) {
    case XK_BackSpace:
        removeCharacter();
        break;
    case XK_Delete:
        deleteCharacter();
        break;
    case XK_Home:
        m_cursorPosition = 0;
        break;
    case XK_End:
        m_cursorPosition = m_url.length();
        break;
    case XK_Left:
        if (m_cursorPosition)
            m_cursorPosition--;
        break;
    case XK_Right:
        if (m_cursorPosition < m_url.length())
            m_cursorPosition++;
        break;
    case XK_Return:
        loadPage();
        break;
    case XK_Insert:
        if (event.state & ControlMask)
            becomeClipboardOwner();
        else if (event.state & ShiftMask)
            requestClipboardText();
        break;
    default:
        if (event.state & ControlMask) {
            // while the Control key is pressed, character codes start from 1 (A=1, B=2, ...).
            switch (normalKey + 'A' - 1) {
            case 'C':
                becomeClipboardOwner();
                break;
            case 'V':
                requestClipboardText();
                break;
            }
        } else
            appendCharacter(normalKey);

        break;
    }

    drawUrlBar();
}
Exemplo n.º 5
0
void Game::updateCharacters() {

	connection->connectionMutex.Lock();

	std::map<long, Character> positions = connection->getPlayers();

	connection->connectionMutex.Unlock();

	std::map<long, Character>::iterator pit;


	for (pit = positions.begin(); pit != positions.end(); pit++) {

		if (hasCharacter(pit->first)) {

			window->drawableObjectsMutex.Lock();

			*characters[pit->first] = pit->second;

			window->drawableObjectsMutex.Unlock();

		} else {

			Character *c = new Character(pit->second);
			addCharacter(pit->first, *c);
		}

	}

	if (characters.size() > positions.size()) {
		std::map<long, Character*>::iterator ppit;

		for (ppit = characters.begin(); ppit != characters.end(); ppit++) {

			if (positions.find(ppit->first) == positions.end()) {
				deleteCharacter(ppit->first);
			}

		}
	}

}
Exemplo n.º 6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    database(0),
    eventsFilterModel(new QSortFilterProxyModel(this)),
    conversationsTreeModel(new TableToTreeProxyModel(this)),
    hideEventsTableColumnsModel(new HideColumnsProxyModel(this))
{
    ui->setupUi(this);

    eventsFilterModel->setObjectName("eventsFilterModel");

    hideEventsTableColumnsModel->setObjectName("hideEventsTableColumnsModel");
    QList<int> hideColumns;
    hideColumns << 0 << 1 << 4 << 5;
    hideEventsTableColumnsModel->setHideColumns(hideColumns);

    conversationsTreeModel = new TableToTreeProxyModel(this);
    conversationsTreeModel->setObjectName("conversationsTreeModel");

    QString fileName = settings.value("database").toString();

    if (fileName.isEmpty() || !QFile(fileName).exists()) {
        newFile();
    }
    else {
        openFile(fileName);
    }

    ui->statusBar->hide();

    ui->splitter->setStretchFactor(1, 1);
    QVariant treeSize = settings.value("treeSize");
    QVariant tableSize = settings.value("tableSize");
    if (treeSize.isValid() && tableSize.isValid()) {
        QList<int> splitterSizes;
        splitterSizes << treeSize.toInt() << tableSize.toInt();
        ui->splitter->setSizes(splitterSizes);
    }

    // TODO: Disable actions that need new e.g. characters until ready
    connect(ui->actionNew, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openFile()));
    connect(ui->actionAdd_Event, SIGNAL(triggered()), this, SLOT(addEvent()));
    connect(ui->actionDelete_Event, SIGNAL(triggered()), this, SLOT(deleteEvent()));
    connect(ui->actionAdd_Conversation, SIGNAL(triggered()), this, SLOT(addConversation()));
    connect(ui->actionDelete_Conversation, SIGNAL(triggered()), this, SLOT(deleteConversation()));
    connect(ui->actionAdd_Character, SIGNAL(triggered()), this, SLOT(addCharacter()));
    connect(ui->actionDelete_Character, SIGNAL(triggered()), this, SLOT(deleteCharacter()));
    connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(openPreferences()));

    ui->conversationsView->installEventFilter(this);
    ui->eventsView->installEventFilter(this);

    connect(ui->conversationsView, SIGNAL(clicked(QModelIndex)),
            this, SLOT(filterOnConversation(QModelIndex)));

    ui->eventsView->setModel(eventsFilterModel);
    ui->eventsView->hideColumn(0);
    ui->eventsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);

    ui->eventsView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->eventsView, SIGNAL(activated(QModelIndex)), this, SLOT(editEvent(QModelIndex)));

    conversationsTreeModel->index(0,0).parent().isValid();
    ui->conversationsView->setModel(conversationsTreeModel);
    ui->conversationsView->sortByColumn(0, Qt::AscendingOrder);

    ui->conversationsView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->conversationsView, SIGNAL(activated(QModelIndex)), this, SLOT(editTreeItem(QModelIndex)));
}
void TransferServerConnection::onReceive(const Archive::ByteStream & message)
{
	Archive::ReadIterator ri = message.begin();
	const GameNetworkMessage msg(ri);
	ri = message.begin();

	if(msg.isType("UploadCharacterMessage"))
	{
		const UploadCharacterMessage ucm(ri);
		CentralServer::getInstance().sendToGameServer(ucm.getFromGameServerId(), ucm, true);
		LOG("TransferServerConnection", ("Received character data for SUID %lu for character object %s on game server %d", ucm.getStationId(), ucm.getFromCharacterId().getValueString().c_str(), ucm.getFromGameServerId()));
	}
	else if(msg.isType("CharacterTransferStatusMessage"))
	{
		const CharacterTransferStatusMessage ctsm(ri);
		CentralServer::getInstance().sendToGameServer(ctsm.getGameServerId(), ctsm, true);
	}
	else if(msg.isType("TransferRequestCharacterList"))
	{
		// simply forward the request to any available login server
		const GenericValueTypeMessage<TransferCharacterData> request(ri);
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
	}
	else if(msg.isType("TransferRequestMoveValidation"))
	{
		const TransferRequestMoveValidation request(ri);
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(request));
		LOG("CustomerService", ("CharacterTransfer: Received TransferRequestMoveValidation : %s on %s to %s on %s. Forwarding request to LoginServer.", request.getSourceCharacter().c_str(), request.getSourceGalaxy().c_str(), request.getDestinationCharacter().c_str(), request.getDestinationGalaxy().c_str()));
	}
	else if(msg.isType("TransferRequestKickConnectedClients"))
	{
		GenericValueTypeMessage<std::pair<unsigned int, unsigned int> > const request(ri);
		// disconnect any clients with a connection to SWG services
		GenericValueTypeMessage<unsigned int> kickSource("TransferKickConnectedClients", request.getValue().first);
		GenericValueTypeMessage<unsigned int> kickDestination("TransferKickConnectedClients", request.getValue().second);
		CentralServer::getInstance().sendToAllLoginServers(kickSource);
		CentralServer::getInstance().sendToAllLoginServers(kickDestination);
		CentralServer::getInstance().sendToAllConnectionServers(kickSource, true);
		CentralServer::getInstance().sendToAllConnectionServers(kickDestination, true);
	}
	else if(msg.isType("TransferGetCharacterDataFromLoginServer"))
	{
		const GenericValueTypeMessage<TransferCharacterData> getCharacterData(ri);
		
		// The transfer server has received a move request. The request doesn't
		// contain the source id of the character, character's container or scene
		// information. The LoginServer can retrieve the character ID for the 
		// source station id + character name contained in character data.
		// Forward the request to the login server. It will respond and the
		// message can be routed back to the transfer server for further 
		// processing
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(getCharacterData));
		LOG("CustomerService", ("CharacterTransfer: ***CentralServer: received TransferGetCharacterDataFromLoginServer : %s)", getCharacterData.getValue().toString().c_str()));
	}
	else if(msg.isType("TransferGetLoginLocationData"))
	{
		GenericValueTypeMessage<TransferCharacterData> getLoginData(ri);
		CentralServer::getInstance().sendToDBProcess(getLoginData, true);
		LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferGetLoginLocationData for %s\n", getLoginData.getValue().getSourceCharacterName().c_str()));
	}
	else if(msg.isType("TransferLoginCharacterToSourceServer"))
	{
		const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
		ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
		if(connectionServer)
		{
			connectionServer->send(loginCharacter, true);
			LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToSourceServer request from Transfer Server. Sendint request to ConnectionServer : %s\n", loginCharacter.getValue().toString().c_str()));
		}
		else
		{
			LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Couldn't find a connection server to satisfy the transfer request for %s\n", loginCharacter.getValue().toString().c_str()));
		}
	}
	else if(msg.isType("TransferLoginCharacterToDestinationServer"))
	{
		const GenericValueTypeMessage<TransferCharacterData> loginCharacter(ri);
		LOG("CustomerService", ("CharacterTransfer: ***CentralServer: Received TransferLoginCharacterToDestinationServer request from Transfer Server for %s\n", loginCharacter.getValue().toString().c_str()));
		ConnectionServerConnection * connectionServer = CentralServer::getInstance().getAnyConnectionServer();
		if(connectionServer)
		{
			connectionServer->send(loginCharacter, true);
		}
	}
	else if(msg.isType("ToggleAvatarLoginStatus"))
	{
		ToggleAvatarLoginStatus toggle(ri);
		LOG("CustomerService", ("CharacterTransfer: Received ToggleAvatarLoginStatus for station ID %d, Character Object %s", toggle.getStationId(), toggle.getCharacterId().getValueString().c_str()));
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(toggle));
	}
	else if(msg.isType("TransferRequestNameValidation"))
	{
		GenericValueTypeMessage<TransferCharacterData> request(ri);
		LOG("CustomerService", ("CharacterTransfer: Received TransferRequestNameValidation from TransferServer. Forwarding request to a random GameServer. %s", request.getValue().toString().c_str()));
		IGNORE_RETURN(CentralServer::getInstance().sendToRandomGameServer(request));
	}
	else if(msg.isType("TransferRenameCharacter"))
	{
		GenericValueTypeMessage<TransferCharacterData> renameRequest(ri);
		LOG("CustomerService", ("CharacterTransfer: Received TransferRenameCharacter. Sending rename request to game database. %s", renameRequest.getValue().toString().c_str()));
		// send first portion of request to DBProcess , wait for response
		CentralServer::getInstance().sendToDBProcess(renameRequest, true);
	}
	else if(msg.isType("TransferAccountRequestLoginServer"))
	{
		// got message to transfer a character from one account to another - have to update in loginServer
		GenericValueTypeMessage<TransferAccountData> accountTransferRequest(ri);
		LOG("CustomerService", ("CharacterTransfer: Received TransferAccountRequestLoginServer from station ID %d to station ID %d", accountTransferRequest.getValue().getSourceStationId(), accountTransferRequest.getValue().getDestinationStationId()));
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(accountTransferRequest));
	}
	else if(msg.isType("RequestChatTransferAvatar"))
	{
		GenericValueTypeMessage<TransferCharacterData> chatTransferAvatar(ri);
		LOG("CustomerService", ("CharacterTransfer: Received RequestChatTransferAvatar from TransferServer. Forward request to ChatServer. %s", chatTransferAvatar.getValue().toString().c_str()));
		CentralServer::getInstance().broadcastToChatServers(chatTransferAvatar);
	}
	else if(msg.isType("DeleteFailedTransfer"))
	{
		GenericValueTypeMessage<TransferCharacterData> deleteCharacter(ri);
		LOG("CustomerService", ("CharacterTransfer: received request to delete a character for a failed transfer. %s", deleteCharacter.getValue().toString().c_str()));
		IGNORE_RETURN(CentralServer::getInstance().sendToArbitraryLoginServer(deleteCharacter));
	}
	else if(msg.isType("TransferClosePseudoClientConnection"))
	{
		GenericValueTypeMessage<unsigned int> closeRequest(ri);
		CentralServer::getInstance().sendToAllConnectionServers(closeRequest, true);
	}
	else if(msg.isType("ConGenericMessage"))
	{
		ConGenericMessage con(ri);
		ConsoleConnection::onCommandComplete(con.getMsg(), static_cast<int>(con.getMsgId()));	 
	}
}
Exemplo n.º 8
0
	/** イベント処理 */
	void TextArea::processEvent(Event* event)
	{
		// 非活性の時はイベントを受け付けない
		if (getEnabled() == false) return;

		// キー押下
		if (event->getType() == KeyEvent::KEY_PRESSED) {
			int keycode = ((KeyEvent *)event)->getKeycode();
			if (keycode == KeyEvent::VKEY_BACKSPACE) {
				if (_ptr_x > 0 || _ptr_y > 0) {
					// バックスペース
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DELETE) {
				// 一文字削除
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					deleteCharacter();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_INSERT) {
				// 上書き設定変更
				_overwrite = !_overwrite;
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_LEFT) {
				// ←移動
				if( _ptr_x != 0 || _ptr_y != 0 ) {
					SetPos( XY2P(_ptr_x,_ptr_y) - 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_RIGHT) {
				// →移動
				if (text[XY2P(_ptr_x,_ptr_y)] != '\0' ) {
					SetPos( XY2P(_ptr_x,_ptr_y) + 1 );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_UP) {
				// ↑移動
				if (_ptr_y > 0) {
					SetPos( XY2P(_ptr_x,_ptr_y-1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_DOWN) {
				// ↓移動
				if (_ptr_y < LineCount()-1) {
					SetPos( XY2P(_ptr_x,_ptr_y+1) );
					OffsetChange();
					updateScrollbar();
					/*if (firstpaint == true)*/ repaint();
				}
			} else if (keycode == KeyEvent::VKEY_PGUP) {
				// 前ページ
				_ptr_y -= _max_line - 1;
				if( _ptr_y < 0 ) _ptr_y = 0;
				_offset_y -= _max_line - 1;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_PGDOWN) {
				// 次ページ
				_ptr_y += _max_line - 1;
				if( _ptr_y > LineCount() ) _ptr_y = LineCount();
				_offset_y += _max_line - 1;
				if( _offset_y > LineCount() - _max_line / 2 ) _offset_y = LineCount() - _max_line / 2;
				if( _offset_y < 0 ) _offset_y = 0;
				SetPos( XY2P(_ptr_x,_ptr_y) );
				OffsetChange();
				updateScrollbar();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_HOME) {
				// 行の先頭へ移動
				SetPos( Y2P(_ptr_y) );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_END) {
				// 行の末尾へ移動
				SetPos( Y2P(_ptr_y+1) - 1 );
				OffsetChange();
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_TAB) {
				// タブの挿入
				insertCharacter( '\t' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode == KeyEvent::VKEY_ENTER) {
				// 改行
				insertCharacter( '\n' );
				/*if (firstpaint == true)*/ repaint();
			} else if (keycode < 128) {
				// 1文字挿入
				if (_overwrite && text[XY2P(_ptr_x,_ptr_y)] != '\n') deleteCharacter();
				insertCharacter(keycode);
				/*if (firstpaint == true)*/ repaint();
			}
		// マウスで押された
		} else if (event->getType() == MouseEvent::MOUSE_PRESSED) {
			int ry = ((MouseEvent*)event)->getY();
			int rx = ((MouseEvent*)event)->getX();
			int fh = getFontMetrics()->getHeight(WIDTH_BASE);
			int fw = getFontMetrics()->getWidth(WIDTH_BASE);
			
			int draw_left = 4 - (fw >> 1);
			int draw_top = 4;
			if( _draw_line ) {
				draw_left += 2 + _keta * fw;
			}
			draw_left -= _offset_x * fw;
			draw_top -= _offset_y * fh;

			SetPos( XY2P( ( rx - draw_left ) / fw, ( ry - draw_top ) / fh ) );
			OffsetChange();
			/*if (firstpaint == true)*/ repaint();
		// フォーカス状態変更
		} else if (event->getType() == Event::FOCUS_IN || event->getType() == Event::FOCUS_OUT) {