bool EwsSyncFolderHierarchyRequest::Response::changeReader(QXmlStreamReader &reader, QVariant &val)
{
    Change::List changes;
    QString elmName(reader.name().toString());

    while (reader.readNextStartElement()) {
        Change change(reader);
        if (!change.isValid()) {
            qCWarningNC(EWSRES_LOG) << QStringLiteral("Failed to read %1 element").arg(elmName);
            return false;
        }
        changes.append(change);
    }

    val = QVariant::fromValue<Change::List>(changes);
    return true;
}
Beispiel #2
0
    void addCustomChanges( Change::List &changes )
    {
#if 0
        KCal::CalendarResourceManager m1( "calendar" );
        m1.readConfig();
        KCal::CalendarResourceManager::Iterator it;
        for ( it = m1.begin(); it != m1.end(); ++it ) {
            if ( (*it)->type() == "exchange" ) break;
        }
        if ( it == m1.end() ) {
            changes.append( new CreateExchangeKcalResource );
        } else {
            if ( (*it)->identifier() == ExchangeConfig::kcalResource() ) {
                KCal::ExchangePrefs *prefs = static_cast<KCal::ResourceExchange *>( *it )->prefs();
                if ( prefs->url() != exchangeUrl() ||
                        prefs->user() != ExchangeConfig::user() ||
                        prefs->password() != ExchangeConfig::password() ) {
                    changes.append( new UpdateExchangeKcalResource );
                }
            }
        }
        KRES::Manager<KABC::Resource> m2( "contact" );
        m2.readConfig();
        KRES::Manager<KABC::Resource>::Iterator it2;
        for ( it2 = m2.begin(); it2 != m2.end(); ++it2 ) {
            if ( (*it2)->type() == "exchange" ) break;
        }
        if ( it2 == m2.end() ) {
            changes.append( new CreateExchangeKabcResource );
        } else {
            if ( (*it2)->identifier() == ExchangeConfig::kabcResource() ) {
                KABC::ExchangePrefs *prefs = static_cast<KABC::ResourceExchange *>( *it2 )->prefs();
                if ( prefs->url() != exchangeUrl() ||
                        prefs->user() != ExchangeConfig::user() ||
                        prefs->password() != ExchangeConfig::password() ) {
                    changes.append( new UpdateExchangeKabcResource );
                }
            }
        }
#endif
    }
Beispiel #3
0
    virtual void addCustomChanges( Change::List &changes )
    {
      addKorganizerChanges( changes );

      // KMail cruft has been outsourced to kolabkmailchanges.cpp
      createKMailChanges( changes );

      changes.append( new SetupLDAPSearchAccount );

      KCal::CalendarResourceManager m( "calendar" );
      m.readConfig();
      KCal::CalendarResourceManager::Iterator it;
      for ( it = m.begin(); it != m.end(); ++it ) {
        if ( (*it)->type() == "imap" ) break;
      }
      if ( it == m.end() ) {
        changes.append( new CreateCalendarImapResource );
        changes.append( new CreateContactImapResource );
        changes.append( new CreateNotesImapResource );
      }
    }
		//Get Best Move - 
		//recursive min/max algorithm explores game states and 
		//returns a move and its score, for a specific player
		MoveScore GetBestMove( const GameState& theGame, const int player_index, int abPrune, const int recursive=1)
		{
			const Change& player_change = theGame.GetPlayerChange( theGame.GetCurrentPlayer() );
			const Change& pool = theGame.GetGameChange(); 

			int bestScore = (player_index == theGame.GetCurrentPlayer())?
							std::numeric_limits<int>::min()
							:
							std::numeric_limits<int>::max();

			Coin bestCoin;
			Change bestChange;

			Change::List* someChange;
			if (recycledChangeLists.empty()){
				someChange = new Change::List;
			}
			else{
				someChange = recycledChangeLists.back();
				recycledChangeLists.pop_back();
			}

			//for each coin that can be played
			for (const Coin *ci=&COINLIST[0];ci!=&COINLIST[COIN_COUNT];++ci){				
				if (player_change.GetCount(*ci) > 0){
					
					//get all possible sets of change into array
					GetAllPossibleChange(
						pool,
						*ci, 
						*someChange);

					//for each possible set of change
					//(reversed iteration improves AB prune by as much as 70%)
					const Change::List::reverse_iterator end = someChange->rend();
					for(Change::List::reverse_iterator i = someChange->rbegin();i!=end;++i){
				
						//create "move" from coin to give, and change to take
						const Move myMove(*ci,*i);
						
						//create gamestate once the move has been played
						GameState newGame = theGame.PlayMove( myMove );

						//get "score" for this move
						int score;
						if (recursive>0 && newGame.GetActivePlayers()>1){
							
							//recursivly examine move, get its score
							score = GetBestMove( newGame, player_index, bestScore, recursive-1).score;						
						}
						else{

							//leaf node - just get heuristic value
							score = GameHeuristic( newGame, player_index, myHeuristic );							
						}
					
						//Min/Max search
						if ((player_index == theGame.GetCurrentPlayer() && score > bestScore) ||
							(player_index != theGame.GetCurrentPlayer() && score < bestScore))
						{
							bestScore  = score;
							bestCoin = *ci;
							bestChange = *i;

							//Alpha/Beta pruning
							if ((player_index == theGame.GetCurrentPlayer() && score > abPrune) ||
								(player_index != theGame.GetCurrentPlayer() && score < abPrune)){

								goto exit;

							}

						}
					}
				}
			}

exit:
			recycledChangeLists.push_back( someChange );						
			return MoveScore( Move( bestCoin, bestChange ), bestScore );
		}
Beispiel #5
0
    void addKorganizerChanges( Change::List &changes )
    {
      KURL freeBusyBaseUrl;
      // usrWriteConfig() is called first, so kolab1Legacy is correct
      if ( KolabConfig::self()->kolab1Legacy() ) {
        freeBusyBaseUrl = "webdavs://" + KolabConfig::self()->server() +
                                "/freebusy/";

      ChangeConfig *c = new ChangeConfig;
      c->file = "korganizerrc";
      c->group = "FreeBusy";

      c->name = "FreeBusyPublishUrl";

      QString user = KolabConfig::self()->user();
      // We now use the full email address in the freebusy URL
      //int pos = user.find( "@" );
      //if ( pos > 0 ) user = user.left( pos );

      KURL publishURL = freeBusyBaseUrl;
      publishURL.addPath( user + ".ifb" ); // this encodes the '@' in the username
      c->value = publishURL.url();

      changes.append( c );

      } else {
          // Kolab2: only need FreeBusyRetrieveUrl
          // "Uploading" is done by triggering a server-side script with an HTTP GET
          // (done by kmail)
          freeBusyBaseUrl = "https://" + KolabConfig::self()->server() +
                            "/freebusy/";
      }

      ChangeConfig *c = new ChangeConfig;
      c->file = "korganizerrc";
      c->group = "FreeBusy";
      c->name = "FreeBusyRetrieveUrl";
      c->value = freeBusyBaseUrl.url();
      changes.append( c );

      // Use full email address for retrieval of free/busy lists
      c = new ChangeConfig;
      c->file = "korganizerrc";
      c->group = "FreeBusy";
      c->name = "FreeBusyFullDomainRetrieval";
      c->value = "true";
      changes.append( c );

      c = new ChangeConfig;
      c->file = "korganizerrc";
      c->group = "Group Scheduling";
      c->name = "Use Groupware Communication";
      c->value = "true";
      changes.append( c );

      // Use identity "from control center", i.e. from emaildefaults
      c = new ChangeConfig;
      c->file = "korganizerrc";
      c->group = "Personal Settings";
      c->name = "Use Control Center Email";
      c->value = "true";
      changes.append( c );
    }