예제 #1
0
//Vehicle sort : MOTO
void MainWindow::on_radioButton_clicked()
{
    removeAllRows(ui->table_vehicle);

    std::vector<std::string>buffer;
    int minorV=0;

    for(int i=0; i<_vehicleContainer.size();i++){
        buffer.clear();
        buffer=_vehicleContainer.display(i,Vehicle::moto);
        if(buffer.size()>0)
            renderRowInTable(ui->table_vehicle,i-minorV,buffer);
        else
            minorV++;
    }
}
예제 #2
0
void CommandTableModel::buildFromXml(XmlElement *root)
{
	if (root->getTagName().compare("settings") != 0)
		return;

	removeAllRows();

	XmlElement* setting = root->getFirstChildElement();
	while ((setting) && (m_commandMap))
	{
		if (setting->hasAttribute("controller"))
		{
			MIDI_Message cc(setting->getIntAttribute("channel"), setting->getIntAttribute("controller"), true);
			addRow(cc.channel, cc.controller, true);

			// older versions of MIDI2LR stored the index of the string, so we should attempt to parse this as well
			if (setting->getIntAttribute("command", -1) != -1)
			{
				m_commandMap->addCommandforMessage(setting->getIntAttribute("command"), cc);
			}
			else
			{
				m_commandMap->addCommandforMessage(setting->getStringAttribute("command_string"), cc);
			}
		}
		else if (setting->hasAttribute("note"))
		{
			MIDI_Message note(setting->getIntAttribute("channel"), setting->getIntAttribute("note"), false);
			addRow(note.channel, note.pitch, false);

			// older versions of MIDI2LR stored the index of the string, so we should attempt to parse this as well
			if (setting->getIntAttribute("command", -1) != -1)
			{
				m_commandMap->addCommandforMessage(setting->getIntAttribute("command"), note);
			}
			else
			{
				m_commandMap->addCommandforMessage(setting->getStringAttribute("command_string"), note);
			}
		}
		setting = setting->getNextElement();
	}
}
예제 #3
0
//Copy sort : MOTO
void MainWindow::on_radioButton_6_clicked()
{
    removeAllRows(ui->tableWidget_2);

    std::vector<std::string>buffer;
    int minorV=0;

    for(int i=0; i<_copyContainer.size();i++){
        if(_copyContainer.getCopyContainer()[i+1]->isActive()){
            buffer.clear();
            buffer=_copyContainer.display(i+1,Vehicle::moto);
            if(buffer.size()>0)
                renderRowInTable(ui->tableWidget_2,i-minorV,buffer);
            else
                minorV++;
        }
        else
            minorV++;
    }
}
예제 #4
0
OsStatus
DialByNameDB::load() const
{
    // Critical Section here
    OsLock lock( sLockMutex );
    OsStatus result = OS_SUCCESS;

    if ( m_pFastDB != NULL ) 
    {
        // Clean out the existing DB rows before loading
        // a new set from persistent storage
        removeAllRows ();

        // Query all Identities with 'AutoAttendant' permission set
        PermissionDB * pPermissionDB = PermissionDB::getInstance();
        ResultSet permissionsResultSet;
        pPermissionDB->getIdentities ( "AutoAttendant", permissionsResultSet );

        CredentialDB * pCredentialDB = CredentialDB::getInstance();
        ResultSet credentialsResultSet;

        UtlString identity, permission;
        int numAutoAttendees = permissionsResultSet.getSize();
        for (int index = 0; index < numAutoAttendees; index++)
        {
            // get the next identity
            UtlString identityKey("identity");
            UtlHashMap record;
            permissionsResultSet.getIndex( index, record );
            UtlString identity = *((UtlString*)record.findValue(&identityKey));

            Url identityUrl (identity);
            pCredentialDB->
                getAllCredentials (
                    identityUrl,
                    credentialsResultSet );

            // we should only have one credential! we're 
            // only interested in the uri column's display name
            if ( credentialsResultSet.getSize() == 1)
            {
                UtlString uriKey("uri");
                UtlHashMap record;
                credentialsResultSet.getIndex( 0, record );
                UtlString uri = *((UtlString*)record.findValue(&uriKey));

                // must have a display name present before inserting a row
                // @TODO convert to url and get display name
                UtlHashMap nvPairs;
                if (!uri.isNull())
                {
                    // Null Element value create a special 
                    // char string we have key and value so insert
                    UtlString* contactValue = 
                        new UtlString( uri ); 

                    // Memory Leak fixes, make shallow copies of static keys
                    UtlString* contactKey = 
                        new UtlString( gNp_contactKey );

                    nvPairs.insertKeyAndValue ( 
                        contactKey, contactValue );
                }
                // Insert the item row into the IMDB
                insertRow ( nvPairs );
            }
        }

        // Reset the changed flags after a successful load
        SIPDBManager::getInstance()->
            setDatabaseChangedFlag("credential", FALSE);
        SIPDBManager::getInstance()->
            setDatabaseChangedFlag("permission", FALSE);
    } else
    {
        result = OS_FAILED;
    }
    return result;
}
예제 #5
0
OsStatus
ExtensionDB::load()
{
    // Critical Section here
    OsLock lock( sLockMutex );
    OsStatus result = OS_SUCCESS;

    if ( m_pFastDB != NULL ) 
    {
        // Clean out the existing DB rows before loading
        // a new set from persistent storage
        removeAllRows ();

        UtlString fileName = OsPath::separator + mDatabaseName + ".xml";
        UtlString pathName = SipXecsService::Path(SipXecsService::DatabaseDirType,
                                                  fileName.data());

        OsSysLog::add(FAC_DB, PRI_DEBUG, "ExtensionDB::load loading \"%s\"",
                    pathName.data());

        TiXmlDocument doc ( pathName );

        // Verify that we can load the file (i.e it must exist)
        if( doc.LoadFile() )
        {
            // the checksum is used to determine if the db changed between reloads
            int loadChecksum = 0;
            TiXmlNode * rootNode = doc.FirstChild ("items");
            if (rootNode != NULL)
            {
                // the folder node contains at least the name/displayname/
                // and autodelete elements, it may contain others
                for( TiXmlNode *itemNode = rootNode->FirstChild( "item" );
                     itemNode; 
                     itemNode = itemNode->NextSibling( "item" ) )
                {
                    // Create a hash dictionary for element attributes
                    UtlHashMap nvPairs;

                    for( TiXmlNode *elementNode = itemNode->FirstChild();
                         elementNode; 
                         elementNode = elementNode->NextSibling() )
                    {
                        // Bypass comments and other element types only interested
                        // in parsing element attributes
                        if ( elementNode->Type() == TiXmlNode::ELEMENT )
                        {
                            UtlString elementName = elementNode->Value();
                            UtlString elementValue;

                            result = SIPDBManager::getAttributeValue (
                                *itemNode, elementName, elementValue);

                            // update the load checksum
                            loadChecksum += ( elementName.hash() + elementValue.hash() );
                            if (result == OS_SUCCESS)
                            {
                                UtlString* collectableKey = 
                                    new UtlString( elementName ); 
                                UtlString* collectableValue = 
                                    new UtlString( elementValue ); 
                                nvPairs.insertKeyAndValue ( 
                                    collectableKey, collectableValue );
                            } else if ( elementNode->FirstChild() == NULL )
                            {
                                // NULL Element value create a special 
                                // char string we have key and value so insert
                                UtlString* collectableKey = 
                                    new UtlString( elementName ); 
                                UtlString* collectableValue = 
                                    new UtlString( SPECIAL_IMDB_NULL_VALUE ); 
                                nvPairs.insertKeyAndValue ( 
                                    collectableKey, collectableValue );
                            }
                        }
                    }
                    // Insert the item row into the IMDB
                    insertRow ( nvPairs );
                }
            }
        } else 
        {
            OsSysLog::add(FAC_SIP, PRI_WARNING, "ExtensionDB::load failed to load \"%s\"",
                    pathName.data());
            result = OS_FAILED;
        }
    } else
    {
        result = OS_FAILED;
    }
    return result;
}
예제 #6
0
OsStatus
CallerAliasDB::load()
{
   // Critical Section here
   OsLock lock( sLockMutex );
   OsStatus result = OS_SUCCESS;

   if ( mpFastDB != NULL ) 
   {
      // Clean out the existing DB rows before loading
      // a new set from persistent storage
      removeAllRows ();

      UtlString fileName = DbName + ".xml";
      UtlString pathName = SipXecsService::Path(SipXecsService::DatabaseDirType,
                                                fileName.data());

      OsSysLog::add(FAC_DB, PRI_DEBUG, "CallerAliasDB::load loading '%s'", pathName.data());

      TiXmlDocument doc ( pathName );

      // Verify that we can load the file (i.e it must exist)
      if( doc.LoadFile() )
      {
         TiXmlNode * rootNode = doc.FirstChild ("items");
         if (rootNode != NULL)
         {
            // the folder node contains at least the name/displayname/
            // and autodelete elements, it may contain others
            for( TiXmlNode *itemNode = rootNode->FirstChild( "item" );
                 itemNode; 
                 itemNode = itemNode->NextSibling( "item" ) )
            {
               UtlString identity;
               UtlString domain;
               UtlString alias;
                   
               for( TiXmlNode *elementNode = itemNode->FirstChild();
                    elementNode; 
                    elementNode = elementNode->NextSibling() )
               {
                  // Bypass comments and other element types only interested
                  // in parsing element attributes
                  if ( elementNode->Type() == TiXmlNode::ELEMENT )
                  {
                     UtlString column(elementNode->Value());

                     if (column.compareTo(IdentityKey) == 0)
                     {
                        SIPDBManager::getAttributeValue(*itemNode, column, identity);
                     }
                     else if (column.compareTo(DomainKey) == 0)
                     {
                        SIPDBManager::getAttributeValue(*itemNode, column, domain);
                     }
                     else if (column.compareTo(AliasKey) == 0)
                     {
                        SIPDBManager::getAttributeValue(*itemNode, column, alias);
                     }
                     else
                     {
                        OsSysLog::add(FAC_DB, PRI_ERR,
                                      "Unrecognized column '%s' in item: ignored",
                                      column.data()
                                      );
                     }
                  }
               }
               // Insert the item row into the IMDB
               insertRow (identity, domain, alias);
            }
         }
      }
      else 
      {
         OsSysLog::add(FAC_DB, PRI_WARNING, "CallerAliasDB::load failed to load '%s'",
                       pathName.data());
         result = OS_FAILED;
      }
   }
   else 
   {
      OsSysLog::add(FAC_DB, PRI_ERR, "CallerAliasDB::load failed - no DB");
      result = OS_FAILED;
   }
   return result;
}