//==================================== // storeDataSysp... //------------------------------------ void SaXProcess::storeDataSysp (void) { // .../ //! Store data which has been written to STDOUT after //! a previous sysp process call // ---- QList<QString> data = mProc->readStdout(); QListIterator<QString> in (data); for (; in.current(); ++in) { int id = 0; QString line (*in.current()); QStringList tokens = QStringList::split ( "=>", line ); QString idstr = tokens.first(); QString data = tokens.last(); QStringList datalist = QStringList::split ( ":", data ); QString key = datalist.first(); QString val = datalist.last(); QRegExp idExp ("(\\d+)"); int rpos = idExp.search (idstr,0); if (rpos >= 0) { id = idExp.cap().toInt(); } addID (id); val = val.stripWhiteSpace(); key = key.stripWhiteSpace(); if ((! key.isEmpty()) && (! val.isEmpty())) { setItem (key,val); } } }
//==================================== // storeData... //------------------------------------ void SaXProcess::storeData (void) { // .../ //! Store data which has been written to STDOUT after //! a previous isax process call // ---- QList<QString> data = mProc->readStdout(); QListIterator<QString> in (data); for (; in.current(); ++in) { QString line (*in.current()); QString cnr; QString key; QString val; int index = 0; QStringList tokens = QStringList::split ( ":", line ); for ( QStringList::Iterator in = tokens.begin(); in != tokens.end(); ++in ) { QString item (*in); item = item.stripWhiteSpace(); switch (index) { case 0: cnr = item; break; case 1: key = item; break; case 2: val = item; break; default: bool isNumber = false; if ((key == "Screen") || (key == "Relative")) { QRegExp idExp ("^(\\d+)$"); if (idExp.search (val,0) >= 0) { isNumber=true; } } if ( (((key == "Screen") || (key == "Relative")) && (!isNumber)) || (key == "Modes")||(key == "Virtual") ) { key = key+":"+val; val = item; } else { val = val+":"+item; } break; } index++; } if (val.isEmpty()) { continue; } addID (cnr.toInt()); setItem (key,val); } }
bool SSIManager::newItem( const Oscar::SSI& item ) { if ( d->SSIList.findIndex( item ) != -1 ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Item is already in list." << endl; return false; } kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Adding item " << item.toString() << endl; d->SSIList.append( item ); addID( item ); return true; }
bool SSIManager::newContact( const Oscar::SSI& contact ) { if ( d->SSIList.findIndex( contact ) == -1 ) { kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding contact '" << contact.name() << "' to SSI list" << endl; addID( contact ); d->SSIList.append( contact ); emit contactAdded( contact ); } else return false; return true; }
bool SSIManager::newGroup( const Oscar::SSI& group ) { //trying to find the group by its ID QValueList<Oscar::SSI>::iterator it, listEnd = d->SSIList.end(); if ( findGroup( group.name() ).isValid() ) return false; if ( !group.name().isEmpty() ) //avoid the group with gid 0 and bid 0 { // the group is really new kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Adding group '" << group.name() << "' to SSI list" << endl; d->SSIList.append( group ); addID( group ); emit groupAdded( group ); return true; } return false; }
//==================================== // merge data into object... //------------------------------------ void SaXStorage::merge (QList< QDict<QString> > data) { // .../ //! merge the data records from the list (data) into //! the corresponding data records of the object. If //! a record does not exist it will be created // ---- for (unsigned int n=0;n<data.count();n++) { QDict<QString>* table = data.at(n); QDictIterator<QString> it (*table); if (! table) { continue; } addID (n); setID (n); for (; it.current(); ++it) { setItem (it.currentKey(),*it.current()); } } }
bool SSIManager::updateItem( const Oscar::SSI& item ) { Oscar::SSI oldItem = findItem( item.name(), item.type() ); if ( oldItem.isValid() ) { removeID( oldItem ); d->SSIList.remove( oldItem ); } if ( d->SSIList.findIndex( item ) != -1 ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New item is already in list." << endl; return false; } kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating item in SSI list" << endl; addID( item ); d->SSIList.append( item ); return true; }
bool SSIManager::updateContact( const Oscar::SSI& contact ) { Oscar::SSI oldContact = findContact( contact.name() ); if ( oldContact.isValid() ) { removeID( oldContact ); d->SSIList.remove( oldContact ); } if ( d->SSIList.findIndex( contact ) != -1 ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New contact is already in list." << endl; return false; } kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating contact '" << contact.name() << "' in SSI list" << endl; addID( contact ); d->SSIList.append( contact ); emit contactUpdated( contact ); return true; }
bool SSIManager::updateGroup( const Oscar::SSI& group ) { Oscar::SSI oldGroup = findGroup( group.name() ); if ( oldGroup.isValid() ) { removeID( oldGroup ); d->SSIList.remove( oldGroup ); } if ( d->SSIList.findIndex( group ) != -1 ) { kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "New group is already in list." << endl; return false; } kdDebug( OSCAR_RAW_DEBUG ) << k_funcinfo << "Updating group '" << group.name() << "' in SSI list" << endl; d->SSIList.append( group ); addID( group ); emit groupUpdated( group ); return true; }