Esempio n. 1
0
 /** 
  * Uses sub-function for each bigger group of tags.
  */
 void ConfigReader::readConfig() {
     configXmlDoc = xmlReadFile(m_config->configPath().c_str(), NULL, 0);
     if(configXmlDoc == NULL) {
         _inf(
                 "%sThere is no config file (~/.keyfrog/config).\n"
                 "You must create one. You can use example config included with keyfrog.\n"
                 "It should be placed at `/usr/share/keyfrog/doc/sample-config' or\n"
                 "`/usr/local/share/keyfrog/doc/sample-config'. If it's not there,\n"
                 "download sources and check doc/ directory.%s\n"
                 , ccyan, creset);
     }
     xmlNode *rootElement = xmlDocGetRootElement(configXmlDoc);
     // Walk through nodes and invoke proper processing functions
     for (xmlNode * cur_node = rootElement->children; cur_node; cur_node = cur_node->next) {
         if (cur_node->type != XML_ELEMENT_NODE) {
             continue;
         }
         if(0==xmlStrcmp((const xmlChar *)"application-groups",cur_node->name)) {
             processGroups(cur_node->children);
         }
         if(0==xmlStrcmp((const xmlChar *)"options",cur_node->name)) {
             processOptions(cur_node->children);
         }
     }
     xmlFreeDoc(configXmlDoc);
 }
Esempio n. 2
0
Action::ResultE MergeGraphOp::traverseLeave(Node * const node, Action::ResultE res)
{
    processGroups(node);
    processTransformations(node);
    processGeometries(node);
    return res;
}
Esempio n. 3
0
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){

	ofPoint velocity = ofPoint(x,y) - oldMousePos;
	oldMousePos = ofPoint(x, y);

	if (objhitidx>=0) {

		objects[objhitidx].rect = objects[objhitidx].rect + velocity;
		objects[objhitidx].setvel(velocity);
		
		processGroups();

	} else if (grouphitidx>=0) {

		groups[grouphitidx].rect = groups[grouphitidx].rect + velocity;

		for (int i=0; i<groups[grouphitidx].objectIndices.size(); i++)
		{

			int idx = groups[grouphitidx].objectIndices[i];
			objects[idx].rect = objects[idx].rect + velocity;

		}

	}

}
Esempio n. 4
0
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button) {


	if (objhitidx>=0) {

		if (objects[objhitidx].vel.length()<3) {

			int nx = objects[objhitidx].rect.x;
			int ny = objects[objhitidx].rect.y;

			nx = int(round((float)nx/snap) * snap);
			ny = int(round((float)ny/snap) * snap);

			objects[objhitidx].rect.x = nx;
			objects[objhitidx].rect.y = ny;

			objects[objhitidx].vel = ofVec2f(0,0);
		}

	}

	

	if (grouphitidx>=0) {

		for (int i=0; i<groups[grouphitidx].objectIndices.size(); i++)
		{

			int idx = groups[grouphitidx].objectIndices[i];

			int nx = objects[idx].rect.x;
			int ny = objects[idx].rect.y;

			nx = int(round((float)nx/snap) * snap);
			ny = int(round((float)ny/snap) * snap);

			objects[idx].rect.x = nx;
			objects[idx].rect.y = ny;			

		}	
	}

	
	

	objhitidx = -1;
	grouphitidx = -1;

	processGroups();

}
Esempio n. 5
0
//--------------------------------------------------------------
void testApp::setup(){


	oldMousePos = ofPoint(0, 0);

	objhitidx = -1;
	grouphitidx = -1;
	margin = 20;
	snap = 20;
	depthIdx = 0;

	processGroups();

}
Esempio n. 6
0
/**
 * Process two groups and ensure the Result string is set properly on the final
 * algorithm.
 *
 * @return A boolean true if execution was sucessful, false otherwise
 */
bool CompareWorkspaces::processGroups() {
  m_Result = true;
  m_Messages->setRowCount(0); // Clear table

  // Get workspaces
  Workspace_const_sptr w1 = getProperty("Workspace1");
  Workspace_const_sptr w2 = getProperty("Workspace2");

  // Attempt to cast to WorkspaceGroups (will be nullptr on failure)
  WorkspaceGroup_const_sptr ws1 =
      boost::dynamic_pointer_cast<const WorkspaceGroup>(w1);
  WorkspaceGroup_const_sptr ws2 =
      boost::dynamic_pointer_cast<const WorkspaceGroup>(w2);

  if (ws1 && ws2) { // Both are groups
    processGroups(ws1, ws2);
  } else if (!ws1 && !ws2) { // Neither are groups (shouldn't happen)
    m_Result = false;
    throw std::runtime_error("CompareWorkspaces::processGroups - Neither "
                             "input is a WorkspaceGroup. This is a logical "
                             "error in the code.");
  } else if (!ws1 || !ws2) {
    recordMismatch(
        "Type mismatch. One workspace is a group, the other is not.");
  }

  if (m_Result && ws1 && ws2) {
    g_log.notice() << "All workspaces in workspace groups \"" << ws1->name()
                   << "\" and \"" << ws2->name() << "\" matched!" << std::endl;
  }

  setProperty("Result", m_Result);
  setProperty("Messages", m_Messages);

  // Store output workspace in AnalysisDataService
  if (!isChild())
    this->store();

  setExecuted(true);
  notificationCenter().postNotification(
      new FinishedNotification(this, this->isExecuted()));

  return true;
}
Esempio n. 7
0
void SmbView::endProcess()
{
    switch(m_state)
    {
        case GroupListing:
            processGroups();
            break;
        case ServerListing:
            processServers();
            break;
        case ShareListing:
            processShares();
            break;
        default:
            break;
    }
    m_state = Idle;
    QApplication::restoreOverrideCursor();
    emit running(false);
    // clean up for future usage
    m_proc->clearArguments();
}
Esempio n. 8
0
/**
 * Process two groups and ensure the Result string is set properly on the final
 * algorithm.
 *
 * @return A boolean true if execution was sucessful, false otherwise
 */
bool CompareWorkspaces::processGroups() {
  m_result = true;
  m_messages->setRowCount(0); // Clear table

  // Get workspaces
  Workspace_const_sptr w1 = getProperty("Workspace1");
  Workspace_const_sptr w2 = getProperty("Workspace2");

  // Attempt to cast to WorkspaceGroups (will be nullptr on failure)
  WorkspaceGroup_const_sptr ws1 =
      boost::dynamic_pointer_cast<const WorkspaceGroup>(w1);
  WorkspaceGroup_const_sptr ws2 =
      boost::dynamic_pointer_cast<const WorkspaceGroup>(w2);

  if (ws1 && ws2) { // Both are groups
    processGroups(ws1, ws2);
  } else if (!ws1 && !ws2) { // Neither are groups (shouldn't happen)
    m_result = false;
    throw std::runtime_error("CompareWorkspaces::processGroups - Neither "
                             "input is a WorkspaceGroup. This is a logical "
                             "error in the code.");
  } else if (!ws1 || !ws2) {
    recordMismatch(
        "Type mismatch. One workspace is a group, the other is not.");
  }

  if (m_result && ws1 && ws2) {
    g_log.notice() << "All workspaces in workspace groups \"" << ws1->getName()
                   << "\" and \"" << ws2->getName() << "\" matched!\n";
  }

  setProperty("Result", m_result);
  setProperty("Messages", m_messages);

  return true;
}
Esempio n. 9
0
void SyncMaster::serverGroupStatus(QList<ForumSubscription*> &subs) { // Temp objects!
    fdb.checkSanity();
    // Update local subs
    for(ForumSubscription *serverSub : subs) {
        ForumSubscription *dbSub = fdb.findById(serverSub->id());
        if(!dbSub) { // Whole forum not found in db - add it
            qDebug() << Q_FUNC_INFO << "Forum not in db -  must add it!";
            ForumSubscription *newSub = ForumSubscription::newForProvider(serverSub->provider(), &fdb, false);
            newSub->copyFrom(serverSub);
            fdb.addSubscription(newSub);
            dbSub = newSub;
        } else { // Sub already in db, just update it
            QString username, password;
            bool localIsAuthenticated = false;
            if(!dbSub->username().isEmpty()) {
                username = dbSub->username();
                password = dbSub->password();
                localIsAuthenticated = true;
            }
            dbSub->copyFrom(serverSub);
            dbSub->setUsername(username);
            dbSub->setPassword(password);
            if(localIsAuthenticated) dbSub->setAuthenticated(true);
            // UpdateEngine will get the missing credentials if
            // forum is authenticated but no u/p are known

            // Check for unsubscribed groups
            for(ForumGroup *dbGrp : dbSub->values()) {
                bool groupIsSubscribed = false;
                for(ForumGroup *serverGrp : serverSub->values()) {
                    if(dbGrp->id() == serverGrp->id())
                        groupIsSubscribed = true;
                }
                dbGrp->setSubscribed(groupIsSubscribed);
                dbGrp->commitChanges();
            }
        }
        Q_ASSERT(dbSub);
    }
    // Check for deleted subs
    QQueue<ForumSubscription*> deletedSubs;
    for(ForumSubscription *dbSub : fdb) {
        bool found = false;
        for(ForumSubscription *serverSub : subs) {
            if(serverSub->id()==dbSub->id())
                found = true;
        }
        // Sub in db not found in sync message - delete it
        if(!found) deletedSubs.append(dbSub);
    }
    while(!deletedSubs.isEmpty())
        fdb.deleteSubscription(deletedSubs.takeFirst());

    // Update group lists
    for(ForumSubscription *serverSub : subs) {
        for(ForumGroup *serverGrp : serverSub->values()) {
            Q_ASSERT(serverGrp->subscription()->id() >= 0 || serverGrp->id().length() > 0);
            ForumSubscription *dbSub = fdb.findById(serverGrp->subscription()->id());
            Q_ASSERT(dbSub);

            ForumGroup *dbGroup = dbSub->value(serverGrp->id());
            if(!dbGroup) { // Group doesn't exist yet
                qDebug() << Q_FUNC_INFO << "Group " << serverGrp->toString() << " not in db -  must add it!";
                ForumGroup *newGroup = new ForumGroup(dbSub, false);
                serverGrp->setName(UNKNOWN_SUBJECT);
                serverGrp->setChangeset(-1); // Force update of group contents
                serverGrp->markToBeUpdated();
                serverGrp->setSubscribed(true);
                newGroup->copyFrom(serverGrp);
                newGroup->setChangeset(-2); // .. by setting changesets different
                dbSub->addGroup(newGroup);
                dbGroup = newGroup;
            }

            Q_ASSERT(dbGroup);

            if(dbGroup->changeset() != serverGrp->changeset()) {
                if(!dbGroup->subscription()->beingUpdated()) {
                    qDebug() << Q_FUNC_INFO << "Adding group to download queue and setting changeset " << dbGroup->toString();
                    dbGroup->setChangeset(serverGrp->changeset());
                    groupsToDownload.append(dbGroup);
                    dbGroup->subscription()->setScheduledForSync(true);
                } else {
                    qDebug() << Q_FUNC_INFO << "NOT adding group to dl queue because it's being updated' " << dbGroup->toString();
                }
            }
            dbGroup->commitChanges();
        }
    }

    processGroups();
}