コード例 #1
0
ファイル: sprite.cpp プロジェクト: havlenapetr/Scummvm
Sprite::Sprite(SagaEngine *vm) : _vm(vm) {
	debug(8, "Initializing sprite subsystem...");

	// Load sprite module resource context
	_spriteContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
	if (_spriteContext == NULL) {
		error("Sprite::Sprite resource context not found");
	}

	_decodeBufLen = DECODE_BUF_LEN;

	_decodeBuf = (byte *)malloc(_decodeBufLen);
	if (_decodeBuf == NULL) {
		memoryError("Sprite::Sprite");
	}

	if (_vm->getGameId() == GID_ITE) {
		loadList(_vm->getResourceDescription()->mainSpritesResourceId, _mainSprites);
		_arrowSprites = _saveReminderSprites = _inventorySprites = _mainSprites;
#ifdef ENABLE_IHNM
	} else if (_vm->getGameId() == GID_IHNM) {
		if (_vm->getFeatures() & GF_IHNM_DEMO) {
			loadList(RID_IHNMDEMO_ARROW_SPRITES, _arrowSprites);
			loadList(RID_IHNMDEMO_SAVEREMINDER_SPRITES, _saveReminderSprites);
		} else {
			loadList(RID_IHNM_ARROW_SPRITES, _arrowSprites);
			loadList(RID_IHNM_SAVEREMINDER_SPRITES, _saveReminderSprites);
		}
#endif
	} else {
		error("Sprite: unknown game type");
	}
}
コード例 #2
0
void AddonsScreen::onUpdate(float dt, irr::video::IVideoDriver*)
{
    if (m_reloading)
    {
        if(UserConfigParams::m_internet_status!=INetworkHttp::IPERM_ALLOWED)
        {
            // not allowed to access the net. how did you get to this menu in
            // the first place??
            loadList();
            m_reloading = false;
        }
        else if (addons_manager->wasError())
        {
            m_reloading = false;
            new MessageDialog( _("Sorry, an error occurred while contacting "
                                 "the add-ons website. Make sure you are "
                                 "connected to the Internet and that "
                                 "SuperTuxKart is not blocked by a firewall"));
            loadList();
        }
        else if (addons_manager->onlineReady())
        {
            m_reloading = false;
            loadList();
        }
        else
        {
            // Addons manager is still initialising/downloading.
        }
    }
}   // onUpdate
コード例 #3
0
// ----------------------------------------------------------------------------
void AddonsScreen::eventCallback(GUIEngine::Widget* widget, 
                                 const std::string& name, const int playerID)
{
    if (name == "back")
    {
        StateManager::get()->escapePressed();
    }

    else if (name == "reload")
    {
        if (!m_reloading)
        {
            m_reloading = true;
            INetworkHttp::get()->insertReInit();
            
            GUIEngine::ListWidget* w_list = 
            getWidget<GUIEngine::ListWidget>("list_addons");
            w_list->clear();
            
            w_list->addItem("spacer", L"");
            w_list->addItem("loading",
                            _("Please wait while addons are updated"),
                            m_icon_loading);
        }
    }

    else if (name == "list_addons")
    {
        GUIEngine::ListWidget* list = 
            getWidget<GUIEngine::ListWidget>("list_addons");
        std::string id = list->getSelectionInternalName();

        if (!id.empty() && addons_manager->getAddon(id) != NULL)
        {
            m_selected_index = list->getSelectionID();
            new AddonsLoading(0.8f, 0.8f, id);
        }
    }
    if (name == "category")
    {
        std::string selection = ((GUIEngine::RibbonWidget*)widget)
                         ->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
        if (selection == "tab_track")
        {
            m_type = "track";
            loadList();
        }
        else if (selection == "tab_kart")
        {
            m_type = "kart";
            loadList();
        }
        else if (selection == "tab_arena")
        {
            m_type = "arena";
            loadList();
        }
    }
}   // eventCallback
コード例 #4
0
int main(int argc, char** argv) {
  init(argc, argv);

  std::string descriptors_file1 = argv[1];
  std::string descriptors_file2 = argv[2];
  std::string matches_file = argv[3];

  bool ok;

  // Load descriptors.
  DescriptorReader descriptor_reader;
  std::deque<Descriptor> descriptors1;
  ok = loadList(descriptors_file1, descriptors1, descriptor_reader);
  CHECK(ok) << "Could not load first descriptors file";
  LOG(INFO) << "Loaded " << descriptors1.size() << " descriptors";

  std::deque<Descriptor> descriptors2;
  ok = loadList(descriptors_file2, descriptors2, descriptor_reader);
  CHECK(ok) << "Could not load second descriptors file";
  LOG(INFO) << "Loaded " << descriptors2.size() << " descriptors";

  if (FLAGS_unique) {
    // Find one match in each direction.
    std::vector<UniqueQueryResult> forward_matches;
    findUniqueMatchesUsingEuclideanDistance(descriptors1, descriptors2,
        forward_matches, FLAGS_use_flann);

    // Convert from query to match representation.
    std::vector<UniqueMatchResult> matches;
    convertUniqueQueryResultsToMatches(forward_matches, matches, true);
    LOG(INFO) << "Found " << matches.size() << " matches";

    UniqueMatchResultWriter writer;
    ok = saveList(matches_file, matches, writer);
    CHECK(ok) << "Could not save list of matches";
  } else {
    // Find several matches in each direction.
    std::deque<QueryResultList> forward_matches;
    findMatchesUsingEuclideanDistance(descriptors1, descriptors2,
        forward_matches, FLAGS_use_max_num, FLAGS_max_num,
        FLAGS_use_absolute_threshold, FLAGS_absolute_threshold,
        FLAGS_use_flann);

    // Flatten out lists of query results to match results.
    std::vector<MatchResult> matches;
    convertQueryResultListsToMatches(forward_matches, matches, true);
    LOG(INFO) << "Found " << matches.size() << " matches";

    MatchResultWriter writer;
    ok = saveList(matches_file, matches, writer);
    CHECK(ok) << "Could not save list of matches";
  }

  return 0;
}
コード例 #5
0
void AddonsScreen::init()
{
    Screen::init();
    
    m_reloading = false;
    
	getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();

    GUIEngine::getFont()->setTabStop(0.66f);
    
    if(UserConfigParams::logAddons())
        std::cout << "[addons] Using directory <" + file_manager->getAddonsDir()
              << ">\n";
    
    GUIEngine::ListWidget* w_list = 
        getWidget<GUIEngine::ListWidget>("list_addons");
    
    m_icon_height = getHeight()/8.0f;
    // 128 is the height of the image file
    m_icon_bank->setScale(m_icon_height/128.0f); 
    w_list->setIcons(m_icon_bank, (int)(m_icon_height));
    
    m_type = "kart";
    if (UserConfigParams::m_internet_status != INetworkHttp::IPERM_ALLOWED) 
        getWidget<GUIEngine::ButtonWidget>("reload")->setDeactivated();
    else
        getWidget<GUIEngine::ButtonWidget>("reload")->setActivated();
    


    // Set the default sort order
    Addon::setSortOrder(Addon::SO_DEFAULT);
    loadList();
}   // init
コード例 #6
0
// ----------------------------------------------------------------------------
void AddonsScreen::onColumnClicked(int column_id)
{
    if (m_sort_col != column_id)
    {
        m_sort_desc = false;
        m_sort_default = false;
    }
    else
    {
        if (!m_sort_default) m_sort_desc = !m_sort_desc;
        m_sort_default = !m_sort_desc && !m_sort_default;
    }
    
    m_sort_col = column_id;

    switch(column_id)
    {
    case 0: 
        Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_NAME); 
        break;
    case 1:
        Addon::setSortOrder(m_sort_default ? Addon::SO_DEFAULT : Addon::SO_DATE); 
        break;
    default: assert(0);
    }   // switch
    /** \brief Toggle the sort order after column click **/
    loadList();
}   // onColumnClicked
コード例 #7
0
int VersionSelectDialog::exec()
{
	QDialog::open();
	if (!m_vlist->isLoaded())
		loadList();
	return QDialog::exec();
}
コード例 #8
0
void DiagramPrefsDialog::accept()
{
	if ((fromDateLine->text().length() > 0) && (toDateLine->text().length() > 0) &&
	    (!_list.empty()))
	{
		if (_list[0]->size() == 0) // data will be read from the database (if data has been loaded from file, size is already >0)

			if (_listID > 0 && _stationID > 0)
			{
				std::vector< std::pair<QDateTime, float> > values;
				_db->loadValues(_listID, _stationID,
				                QDateTime::fromString(
				                        fromDateLine->text(),
				                        "dd.MM.yyyy"),
				                QDateTime::fromString(toDateLine->text(),
				                                      "dd.MM.yyyy"), values);
				if (!loadList(values))
					OGSError::box("No data found.");
			}

		// data has been loaded
		if (_list[0]->size() > 0)
		{
			bool window_is_empty(false);
			if (_window == NULL)
			{
				_window = new DetailWindow();
				_window->setAttribute(Qt::WA_DeleteOnClose);
				window_is_empty = true;
			}

			for (size_t i = 0; i < _list.size(); i++)
				if (this->_visability[i]->isChecked())
				{
					_window->addList(_list[i]);
					window_is_empty = false;
				}

			if (!window_is_empty)
			{
				_window->show();
				this->done(QDialog::Accepted);
			}
			else
			{
				delete _window;
				_window = NULL;
				OGSError::box("No dataset selected.");
			}
		}
		else
		{
			OGSError::box("Invalid station data.");
			this->done(QDialog::Rejected);
		}
	}
	else
		OGSError::box("No data found...");
}
コード例 #9
0
ファイル: myqloader.cpp プロジェクト: peterkomar/sct
myQLoader::myQLoader()
{
  findModules();
  load_Icons();
  loadList();
  
  worker = new QProcess(this);
}
コード例 #10
0
/* == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == == */
int main(int argc, char *argv[])
{
	CDLL list;
	int i,direction, k;
	CDLL_NODE *currNode;

	if (argc < 4)
	{
		printf("You must supply 3 values on the cmd line after %s:\n", argv[0]);
		printf("1: name of an input file contaning n names/labels of the members of the circle\n");
		printf("2: an integer:  k < n  ,  indicating that after deleting the selected starting element, k members are skipped before another deletions until all the members are deleted\n");
		printf("3: a string \"CW\" or \"CCW\" for clockwise counter-clockwise. This is the direction\n");
		printf("   you will move as you advance around the ring deleting members\n");
		exit( EXIT_FAILURE );
	}

	k  = atoi(argv[2]); /* assume valid int < n */
	if (strcmp(argv[3],"CW")==0)
		direction = CLOCKWISE; /* follow the NEXT ptr */
	else
		direction = COUNTERCLOCKWISE; /* follow the PREV ptr */

	/* Initialize CDLL (set head ptr NULL and set the cmp function */
	initList(&list, compareString,printString,freeString);
	loadList(&list,argv[1]);
	printf("\nLIST: ");printList(list, CLOCKWISE, BRIEF ); /* we follow the NEXT ptr around the ring, not the PREV ptr */

	do /* prompt user for a member to start the counting with */
	{
		char *name;
		printf("\nchoose a name as the starting point in the circle: ");
		if (!mygetline( &name,stdin)) fatal("mygetline failed in main reading from stdin.");
		currNode = searchList( list, name); // if user enters non-existent name it will ret NULL
		free( name );
	} while (!currNode);

	while (list.head) /* while list has any members left */
	{
		printf("\nDELETING: "); printString( currNode->data, BRIEF); fflush(stdout);
		currNode = deleteNode( &list, currNode, direction );
		if (!currNode)
		{
			printf("  <-- was the last man standing!\n");
			break;
		}
		printf("\nLIST: "); fflush(stdout);
		printList(list, CLOCKWISE, BRIEF );
		printf("RESUMING AT: "); printString( currNode->data, BRIEF ); printf( " and skipping %d elements \n", k );
		for ( i=1 ; i<=k ; ++i )
			if (direction==CLOCKWISE)
				currNode = currNode->next;
			else
				currNode=currNode->prev;

	} /* END WHILE - END OF GAME */
    return EXIT_SUCCESS;
}
コード例 #11
0
// ----------------------------------------------------------------------------
void AddonsScreen::onColumnClicked(int column_id)
{
    switch(column_id)
    {
    case 0: Addon::setSortOrder(Addon::SO_NAME); break;
    case 1: Addon::setSortOrder(Addon::SO_DATE); break;
    default: assert(0);
    }   // switch
    loadList();
}   // onColumnClicked
コード例 #12
0
void KSettingsOnlineQuotes::slotNewEntry()
{
  WebPriceQuoteSource newSource(i18n("New Quote Source"));
  newSource.write();
  loadList();
  QListWidgetItem* item = m_quoteSourceList->findItems(i18n("New Quote Source"), Qt::MatchExactly).at(0);
  if (item) {
    m_quoteSourceList->setCurrentItem(item);
    slotLoadWidgets();
  }
}
コード例 #13
0
ファイル: Trigger.cpp プロジェクト: foxostro/arbarlith2
void Trigger::load(const PropertyBag &xml)
{
	Actor::load(xml);

	loadList(xml, "sounds", sounds);

	if(xml.exists("triggerRadius")) {
		xml.get("triggerRadius", triggerRadius);
	} else {
		triggerRadius = getCylinderRadius(); // default
	}
}
コード例 #14
0
int main(int argc, char** argv) {
  bool ok;

  init(argc, argv);
  std::string keypoints_file = argv[1];
  std::string indices_file = argv[2];
  std::string subset_file = argv[3];

  // Load keypoints.
  std::vector<SiftPosition> keypoints;
  SiftPositionReader feature_reader;
  ok = loadList(keypoints_file, keypoints, feature_reader);
  CHECK(ok) << "Could not load keypoints";
  int num_keypoints = keypoints.size();
  LOG(INFO) << "Loaded " << num_keypoints << " keypoints";

  // Load indices.
  std::vector<int> indices;
  DefaultReader<int> index_reader;
  ok = loadList(indices_file, indices, index_reader);
  CHECK(ok) << "Could not load indices";

  // Extract subset.
  std::vector<SiftPosition> subset;

  std::vector<int>::const_iterator index;
  for (index = indices.begin(); index != indices.end(); ++index) {
    subset.push_back(keypoints[*index]);
  }

  SiftPositionWriter index_writer;
  ok = saveList(subset_file, subset, index_writer);
  CHECK(ok) << "Could not save keypoint subset";
  LOG(INFO) << "Selected " << subset.size() << " / " << num_keypoints <<
      " keypoints";

  return 0;
}
コード例 #15
0
ファイル: listFilesExists.c プロジェクト: BladzheR/FTSv2
int listFilesExists() {

    FILE *list;
    list = fopen("list.xml", "a+");
    if (fgetc(list) == EOF) {
        printf("\nСписок файлов пуст, либо не существует!\nСоздам список,если его нет.\n\n");
        if (loadList() != 0) {
            perror("loadList:");
        } else {
            printf("Обновил список файлов!\n");
        }
    }
    fclose(list);
    return 0;
}
コード例 #16
0
ファイル: recordingdialog.cpp プロジェクト: elemem/ExMplayer
RecordingDialog::RecordingDialog(QWidget *parent) :
    QWidget(parent), pressedItemLeftButton(0), pressedItemRightButton(0)
{
    recordings_directory = "/tmp/";
    recording_quality = 37;
    recording_format = 0;

    setWindowIcon( QPixmap(":/icons/logo.png") );
    setWindowTitle(tr("Recordings"));
    clearListButton = new QPushButton(tr("&Clear list"), this);
    openFolderButton = new QPushButton(tr("&Open folder"), this);
    downloadList = new QListWidget(this);

    QHBoxLayout* hbox = new QHBoxLayout;
    hbox->addWidget(clearListButton);
    hbox->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Preferred));
    hbox->addWidget(openFolderButton);
    hbox->setContentsMargins(7, 4, 7, 3);
    MyBorder* border = new MyBorder(this);
    border ->setBGColor(palette().color(backgroundRole()));

    QVBoxLayout* vbox = new QVBoxLayout(this);
    vbox->addWidget(downloadList);    
    vbox->addWidget(border);
    vbox->addLayout(hbox);
    vbox->setContentsMargins(0,0,0,0);
    vbox->setSpacing(0);    

    RecordingDelegate* delegate = new RecordingDelegate(downloadList);
    downloadList->setItemDelegate(delegate);
    downloadList->setSelectionMode(QAbstractItemView::SingleSelection);
    downloadList->setAlternatingRowColors(true);
    downloadList->viewport()->installEventFilter(this);
    downloadList->setFrameStyle(QFrame::Plain | QFrame::NoFrame);
    downloadList->viewport()->setMouseTracking(true);
    resize(500, 300);
    QAbstractItemModel* downloadModel = downloadList->model();

    connect(clearListButton, SIGNAL(clicked()), this, SLOT(clearList()));    
    connect(downloadModel, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), this, SLOT(updateClearListButton()));
    connect(downloadModel, SIGNAL(rowsInserted(const QModelIndex&, int, int)), this, SLOT(updateClearListButton()));
    connect(downloadList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(videoDoubleClicked(QListWidgetItem*)));
    connect(downloadModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateClearListButton()));
    connect(openFolderButton, SIGNAL(clicked()), this, SLOT(openFolder()));
    loadList();
}
コード例 #17
0
ファイル: MainWindow.cpp プロジェクト: kwent/thumbnailme
/**
*@brief Connection des QAction avec leurs différents slots.
*/
void MainWindow::createMenuConnections()
{
    connect( openMediasAction, SIGNAL(triggered()), mpDockInputOutput, SLOT(loadList()) );
    connect( openSettingsAction, SIGNAL(triggered()), mpIniManager, SLOT(importConf()) );
    connect( openRecentSettingsAction, SIGNAL(aboutToShow()), mpIniManager, SLOT(loadRecentConfs()) );
    connect( saveAction, SIGNAL(triggered()), mpIniManager, SLOT(saveSettings()));
    connect( saveUnderAction, SIGNAL(triggered()), mpIniManager, SLOT(saveSettingsUnder()) );
    connect( settingsAction, SIGNAL(triggered()), mpSettingsWidget, SLOT(show()) );
    connect( fullScreenAction, SIGNAL(triggered()), this, SLOT(manageFullScreen ()) );
    connect( configurationMenu, SIGNAL(triggered(QAction*)), mpDockConf, SLOT(setPredefinedConfiguration(QAction*)) );
    connect( aboutThumbnailMeAction, SIGNAL(triggered()), this, SLOT(aboutThumbnailme()) );
    connect( aboutQtAction, SIGNAL(triggered()), qApp,SLOT(aboutQt()) );
    connect( helpAction, SIGNAL(triggered()), mpHelpWidget,SLOT(show()) );
    connect( donateAction, SIGNAL(triggered()), this,SLOT(donateThumbnailme()) );
    connect( websiteAction, SIGNAL(triggered()), this,SLOT(websiteThumbnailme()) );
    connect( quitAction, SIGNAL(triggered()), this, SLOT(close()) );
}
コード例 #18
0
void PluginManager::init()
      {
      //
      // initialize local shortcut table
      //    we need a deep copy to be able to rewind all
      //    changes on "Abort"
      //
      qDeleteAll(localShortcuts);
      localShortcuts.clear();
      foreach(const Shortcut* s, Shortcut::shortcuts())
            localShortcuts[s->key()] = new Shortcut(*s);
      shortcutsChanged = false;
      loadList(false);
      connect(pluginListWidget, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(pluginLoadToggled(QListWidgetItem*)));
      connect(pluginListWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
              SLOT(pluginListWidgetItemChanged(QListWidgetItem*, QListWidgetItem*)));
}
コード例 #19
0
KSettingsOnlineQuotes::KSettingsOnlineQuotes(QWidget *parent)
    : KSettingsOnlineQuotesDecl(parent),
    m_quoteInEditing(false)
{
  QStringList groups = WebPriceQuote::quoteSources();

  loadList(true /*updateResetList*/);

  m_updateButton->setEnabled(false);

  KGuiItem updateButtenItem(i18nc("Accepts the entered data and stores it", "&Update"),
                            KIcon("dialog-ok"),
                            i18n("Accepts the entered data and stores it"),
                            i18n("Use this to accept the modified data."));
  m_updateButton->setGuiItem(updateButtenItem);

  KGuiItem deleteButtenItem(i18n("&Delete"),
                            KIcon("edit-delete"),
                            i18n("Delete the selected source entry"),
                            i18n("Use this to delete the selected online source entry"));
  m_deleteButton->setGuiItem(deleteButtenItem);

  KGuiItem newButtenItem(i18nc("Create a new source entry for online quotes", "&New..."),
                         KIcon("document-new"),
                         i18n("Create a new source entry for online quotes"),
                         i18n("Use this to create a new entry for online quotes"));
  m_newButton->setGuiItem(newButtenItem);

  connect(m_updateButton, SIGNAL(clicked()), this, SLOT(slotUpdateEntry()));
  connect(m_newButton, SIGNAL(clicked()), this, SLOT(slotNewEntry()));

  connect(m_quoteSourceList, SIGNAL(itemSelectionChanged()), this, SLOT(slotLoadWidgets()));
  connect(m_quoteSourceList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(slotEntryRenamed(QListWidgetItem*)));
  connect(m_quoteSourceList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(slotStartRename(QListWidgetItem*)));

  connect(m_editURL, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged()));
  connect(m_editSymbol, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged()));
  connect(m_editDate, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged()));
  connect(m_editDateFormat, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged()));
  connect(m_editPrice, SIGNAL(textChanged(QString)), this, SLOT(slotEntryChanged()));
  connect(m_skipStripping, SIGNAL(toggled(bool)), this, SLOT(slotEntryChanged()));

  // FIXME deleting a source is not yet implemented
  m_deleteButton->setEnabled(false);
}
コード例 #20
0
void KSettingsOnlineQuotes::resetConfig()
{
  QStringList::ConstIterator it;
  QStringList groups = WebPriceQuote::quoteSources();

  // delete all currently defined entries
  for (it = groups.constBegin(); it != groups.constEnd(); ++it) {
    WebPriceQuoteSource(*it).remove();
  }

  // and write back the one's from the reset list
  QList<WebPriceQuoteSource>::ConstIterator itr;
  for (itr = m_resetList.constBegin(); itr != m_resetList.constEnd(); ++itr) {
    (*itr).write();
  }

  loadList();
}
コード例 #21
0
ファイル: linSearch.c プロジェクト: aqiu384/oblivc-examples
int main(int argc, char *argv[]) {    
    ProtocolDesc pd;
    protocolIO io;
    int i, index = 0;

    if(argc < 3) {
        fprintf(stderr, "Not enough args\n");
        return 1;
    }

    int party = (argv[1][0] == '1' ? 1 : 2);
    protocolUseStdio(&pd);
    
    if (party == 1) {
        loadList(&io);
    }
    else {
        io.n = strtol(argv[2], NULL, 10);
    }
    
    setCurrentParty(&pd, party);

    double lap = wallClock();
    execYaoProtocol(&pd, linSearch, &io);

    fprintf(stderr,"Party: %d\n", party);
    fprintf(stderr,"Total time: %lf s\n", wallClock() - lap);
    
    if (io.res) {
        fprintf(stderr,"Item found.\n\n");
    }
    else {
        fprintf(stderr,"Item not found.\n\n");
    }

    cleanupProtocol(&pd);
    
    if (party == 1) {
        free(io.nList);
    }
    
    return 0;
}
コード例 #22
0
ファイル: PhotoDialog.cpp プロジェクト: N00D13/RetroShare
void PhotoDialog::loadRequest(const TokenQueue *queue, const TokenRequest &req)
{
    std::cerr << "PhotoShare::loadRequest()";
    std::cerr << std::endl;

    if (queue == mPhotoQueue)
    {
        /* now switch on req */
        switch(req.mType)
        {
            case TOKENREQ_MSGINFO:
            {
                switch(req.mAnsType)
                {
                    case RS_TOKREQ_ANSTYPE_DATA:
                        loadComment(req.mToken);
                        break;
                    case RS_TOKREQ_ANSTYPE_LIST:
                        loadList(req.mToken);
                        break;
                    case RS_TOKREQ_ANSTYPE_ACK:
                        acknowledgeComment(req.mToken);
                        break;
                    default:
                        std::cerr << "PhotoShare::loadRequest() ERROR: MSG INVALID TYPE";
                        std::cerr << std::endl;
                        break;
                }
                break;
            }

            default:
            {
                std::cerr << "PhotoShare::loadRequest() ERROR: INVALID TYPE";
                std::cerr << std::endl;
                break;
            }
        }
    }

}
コード例 #23
0
bool Test_LinkedList::test5()
{
	bool isPassed = false;
	LinkedList<int> list;
	std::vector<int> vec;
	printTestMessage("size returns correct value after multiple addBack");

	std::cerr << std::endl;
	for(int i=0; i<TEST_SIZE; i++)
	{
		std::cerr << '\r' << "\tAdding " << (i+1) << "/" << TEST_SIZE << " nodes "; 
		vec.push_back(i);
		std::cerr.flush();
	}
	
	loadList(vec, list);
	
	isPassed = list.size() == TEST_SIZE;
	printPassFail(isPassed);
	return (isPassed); 
}
コード例 #24
0
void MusicCollector::requestFinished()
{
    sender()->deleteLater();
    if (currentReply != sender())
        return;

    emit loadingChanged();

    int nextOpt = nextOperation;
    QString optId = operatingId;

    nextOperation = OperationNone;
    operatingId.clear();

    if (currentReply->error() != QNetworkReply::NoError)
        return;

    QVariantMap resp = parser->parse(currentReply->readAll()).toMap();
    if (resp.value("code", -1).toInt() != 200)
        return;

    int opt = currentReply->property(KeyOperation).toInt();
    if (opt == OperationLoadPid) {
        foreach (const QVariant& playlist, resp.value("playlist").toList()) {
            QVariantMap map = playlist.toMap();
            if (map.value("specialType").toInt() == 5) {
                playlistId = map.value("id").toInt();
                break;
            }
        }
        if (playlistId == 0)
            return;

        if (nextOpt == OperationCollectMusic)
            collectMusic(optId);
        else if (nextOpt == OperationRemoveCollection)
            removeCollection(optId);
        else
            loadList();
    }
コード例 #25
0
ファイル: frecpal.c プロジェクト: aadelop/frecpal
int main (int argc, char * argv[])
{

	list items; //list of items to order
	item * pItem;//

	listInit(&items);

	/*Checker of correct memory allocation*/
	while (((pItem = (item *)malloc(sizeof(item)))==NULL))
	{
		printf("Not enough memmory ,waiting for more memory");
		sleep(3);
	}

	/*Loding list with content from user's file */
	loadList(argv[1],pItem, &items);

	/*Ordring */
	orderFrecpal(argv[2],&items);

} 
コード例 #26
0
ファイル: main.c プロジェクト: MonkFallsInSnow/CS261
int main(int argc, const char * argv[])
{
	char cmd = ' ';
	DynArr* mainList = createDynArr(10);
	char filename[100]; //filename buffer
	FILE* file = NULL; //input/output file

	printf("\n\n** TO-DO LIST APPLICATION **\n\n");

	do
	{
		printf("Press:\n"
			"'l' to load to-do list from a file\n"
			"'s' to save to-do list to a file\n"
			"'a' to add a new task\n"
			"'g' to get the first task\n"
			"'r' to remove the first task\n"
			"'p' to print the list\n"
			"'e' to exit the program\n"
			);
		/* get input command (from the keyboard) */
		cmd = getchar();
		/* clear the trailing newline character */
		while (getchar() != '\n');

		switch (cmd)
		{
		case 'l':
		{
			//get filename
			printf("Enter filename: ");
			scanf("%s", filename);
			getchar();

			//if a file is already open, then close it
			if (file != NULL)
			{
				fclose(file);
			}

			file = fopen(filename, "r"); //open the file for reading

			if (file != NULL) //if the file was opened sucessfully...
			{
				//empty the main list
				if (!isEmptyDynArr(mainList))
				{
					int size = sizeDynArr(mainList);
					for (int i = 0; i < size; i++)
					{
						removeMinHeap(mainList, compare);
					}
				}

				//load the file and print a confirmation
				loadList(mainList, file); 
				printf("List has been loaded.\n\n");
			}
			else //otherwise print and error message
			{
				printf("Could not open file.\n\n");

			}
			break;
		}
		case 's':
		{
			//get filename
			printf("Enter filename: ");
			scanf("%s", filename);
			getchar();

			file = fopen(filename, "w"); //open the file for writing

			if (file != NULL) //if the file was opened sucessfully
			{
				//save the list and print a confirmation
				saveList(mainList, file);
				printf("List has been saved.\n\n");
			}
			else //otherwise print an error message
			{
				printf("Could not create file.\n\n");

			}
			break;
		}
		case 'a':
		{
			int priority; //stores the task priority
			char desc[100]; //sotres the task description

			//get the task description
			printf("Enter a brief description: ");
			fgets(desc, 100, stdin);
			desc[strcspn(desc, "\n")] = 0; //removes trailing newline character

			//get the task priority
			printf("Enter a task priority (0-999): ");
			scanf("%d", &priority);
			getchar();

			TYPE newTask = createTask(priority, desc); //create a new task
			addHeap(mainList, newTask, compare); //add that taks to the heap
			printf("The task '%s' has been added to your list.\n\n", desc); //print a confirmation
			break;
		}
		case 'g':
		{
			if (!isEmptyDynArr(mainList)) //make sure the list is not empty
			{
				struct Task* task = (struct Task*)getMinHeap(mainList); //get the value at the heap's root node
				printf("Your first task is: %s\n\n", task->description); //print the description of that value
			}
			else
			{
				printf("Your to-do list is empty!\n\n"); 
			}
			break;
		}
		case 'r':
		{
			if (!isEmptyDynArr(mainList)) //make sure the heap is not empty
			{
				struct Task* task = (struct Task*)getMinHeap(mainList); //get the value at the heap's root node
				printf("Your first task '%s' has been removed from the list.\n\n", task->description); //print the description of that value
				removeMinHeap(mainList, compare); //remove that value from the heap
				free(task);
				task = NULL;
				
			}
			else
			{
				printf("The list is empty.\n\n");
			}
			break;
		}
		case 'p':
		{
			if (!isEmptyDynArr(mainList)) //make sure the heap is not empty
			{
				printList(mainList); //then print the contents of the heap from highest to lowest priority
			}
			else
			{
				printf("The list is empty.\n\n");
			}
			break;
		}
		case 'e':
		{
			//if a file has been opened, then close that file
			if (file != NULL)
			{
				fclose(file);
			}
			break;
		}
		default:
			break;
		}
		/* Note: We have provided functions called printList(), saveList() and loadList() for you
		to use.  They can be found in toDoList.c */
	} while (cmd != 'e');
	/* delete the list */
	deleteDynArr(mainList);

	return 0;
}
コード例 #27
0
void AntiSpamFrame::loadWhiteList() {
    QList<QString> list = AntiSpam::getInstance()->getWhite();
    loadList(treeWidget_WHITE, list);
}
コード例 #28
0
void AntiSpamFrame::loadGrayList() {
    QList<QString> list = AntiSpam::getInstance()->getGray();
    loadList(treeWidget_GRAY, list);
}
コード例 #29
0
void AntiSpamFrame::loadBlackList() {
    QList<QString> list = AntiSpam::getInstance()->getBlack();
    loadList(treeWidget_BLACK, list);
}
コード例 #30
0
void YahooClient::process_packet()
{
    Params params;
    Params::iterator it;
    for (;;) {
        string key;
        string value;
        if (!m_socket->readBuffer.scan("\xC0\x80", key) || !m_socket->readBuffer.scan("\xC0\x80", value))
            break;
        unsigned key_id = atol(key.c_str());
        params.push_back(PARAM(key_id, value));
        log(L_DEBUG, "Param: %u %s", key_id, value.c_str());
    }
    switch (m_service) {
    case YAHOO_SERVICE_VERIFY:
        if (m_pkt_status != 1) {
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Yahoo! login lock"));
            return;
        }
        addParam(1, getLogin().utf8());
        sendPacket(YAHOO_SERVICE_AUTH);
        break;
    case YAHOO_SERVICE_AUTH:
        process_auth(params[13], params[94], params[1]);
        break;
    case YAHOO_SERVICE_AUTHRESP:
        m_pkt_status = 0;
        if (params[66])
            m_pkt_status = atol(params[66]);
        switch (m_pkt_status) {
        case YAHOO_LOGIN_OK:
            authOk();
            return;
        case YAHOO_LOGIN_PASSWD:
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Login failed"), AuthError);
            return;
        case YAHOO_LOGIN_LOCK:
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Your account has been locked"), AuthError);
            return;
        case YAHOO_LOGIN_DUPL:
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Your account is being used from another location"));
            return;
        default:
            m_socket->error_state(I18N_NOOP("Login failed"));
        }
        break;
    case YAHOO_SERVICE_LIST:
        authOk();
        loadList(params[87]);
        for (it = params.begin(); it != params.end(); ++it) {
            if ((*it).first == 59) {
                string s = (*it).second;
                string n = getToken(s, ' ');
                const char *p = s.c_str();
                for (; *p; ++p)
                    if (*p != ' ')
                        break;
                string cookie = p;
                s = getToken(cookie, ';');
                if (n == "Y")
                    setCookieY(s.c_str());
                if (n == "T")
                    setCookieT(s.c_str());
            }
        }
        break;
    case YAHOO_SERVICE_LOGOFF:
        if (m_pkt_status == (unsigned long)(-1)) {
            m_reconnect = NO_RECONNECT;
            m_socket->error_state(I18N_NOOP("Your account is being used from another location"));
            return;
        }
    case YAHOO_SERVICE_LOGON:
        if (params[1])
            authOk();
    case YAHOO_SERVICE_USERSTAT:
    case YAHOO_SERVICE_ISAWAY:
    case YAHOO_SERVICE_ISBACK:
    case YAHOO_SERVICE_GAMELOGON:
    case YAHOO_SERVICE_GAMELOGOFF:
    case YAHOO_SERVICE_IDACT:
    case YAHOO_SERVICE_IDDEACT:
        if (params[7] && params[13])
            processStatus(m_service, params[7], params[10], params[19], params[47], params[137]);
        break;
    case YAHOO_SERVICE_IDLE:
    case YAHOO_SERVICE_MAILSTAT:
    case YAHOO_SERVICE_CHATINVITE:
    case YAHOO_SERVICE_CALENDAR:
    case YAHOO_SERVICE_NEWPERSONALMAIL:
    case YAHOO_SERVICE_ADDIDENT:
    case YAHOO_SERVICE_ADDIGNORE:
    case YAHOO_SERVICE_PING:
    case YAHOO_SERVICE_GOTGROUPRENAME:
    case YAHOO_SERVICE_GROUPRENAME:
    case YAHOO_SERVICE_PASSTHROUGH2:
    case YAHOO_SERVICE_CHATLOGON:
    case YAHOO_SERVICE_CHATLOGOFF:
    case YAHOO_SERVICE_CHATMSG:
    case YAHOO_SERVICE_REJECTCONTACT:
    case YAHOO_SERVICE_PEERTOPEER:
        break;
    case YAHOO_SERVICE_MESSAGE:
        if (params[4] && params[14])
            process_message(params[4], params[14], params[97]);
        break;
    case YAHOO_SERVICE_NOTIFY:
        if (params[4] && params[49])
            notify(params[4], params[49], params[13]);
        break;
    case YAHOO_SERVICE_NEWCONTACT:
        if (params[1]) {
            contact_added(params[3], params[14]);
            return;
        }
        if (params[7]) {
            processStatus(m_service, params[7], params[10], params[14], params[47], params[137]);
            return;
        }
        if (m_pkt_status == 7)
            contact_rejected(params[3], params[14]);
        break;
    case YAHOO_SERVICE_P2PFILEXFER:
        if ((params[49] == NULL) || strcmp(params[49], "FILEXFER")) {
            log(L_WARN, "Unhandled p2p type %s", params[49]);
            break;
        }
    case YAHOO_SERVICE_FILETRANSFER:
        if (params[4] && params[27] && params[28] && params[14] && params[20])
            process_file(params[4], params[27], params[28], params[14], params[20]);
        break;
    default:
        log(L_WARN, "Unknown service %X", m_service);
    }
}