コード例 #1
0
QColor KOHelper::resourceColor( KCal::Calendar *calendar,
                                KCal::Incidence *incidence )
{
  QColor resourceColor = QColor(); //Default invalid color
  //FIXME: dynamic_cast are dirty, Better We implements interface to get
  // the color from the calendar
  KCal::CalendarResources *calendarResource =
    dynamic_cast<KCal::CalendarResources*>( calendar );

  if ( calendarResource ) {
    KCal::ResourceCalendar *resourceCalendar =
      calendarResource->resource( incidence );

    if ( resourceCalendar ) {
      QString identifier = resourceCalendar->identifier();
      resourceColor = KOPrefs::instance()->resourceColor( identifier );

      if ( !resourceCalendar->subresources().isEmpty() ) {
        identifier = resourceCalendar->subresourceIdentifier( incidence );
        if ( identifier.isEmpty() ) {
          identifier = resourceCalendar->identifier();
        }
        QColor subrescolor( KOPrefs::instance()->resourceColor( identifier ) );
        if ( subrescolor.isValid() ) {
          resourceColor = subrescolor;
        }
      }
    }
  }
  return resourceColor;
}
コード例 #2
0
QColor KOHelper::resourceColor( KCal::Calendar*calendar, KCal::Incidence*incidence )
{
  QColor resourceColor = QColor(); //Default invalid color
  //FIXME: dynamic_cast are dirty, Better We implements interface to get the color
  // from the calendar
  KCal::CalendarResources *calendarResource = dynamic_cast<KCal::CalendarResources*>( calendar );

  if ( calendarResource ) {
    KCal::ResourceCalendar *resourceCalendar = calendarResource->resource( incidence );

    if( resourceCalendar ) {
      QString identifier = resourceCalendar->identifier();
      resourceColor = *KOPrefs::instance()->resourceColor( identifier );

      if ( !resourceCalendar->subresources().isEmpty() ) {
        identifier = resourceCalendar->subresourceIdentifier( incidence );
       if ( identifier.isEmpty() )
         identifier = resourceCalendar->identifier();
       QColor subrescolor( *KOPrefs::instance()->resourceColor( identifier ) );
       if ( subrescolor.isValid() )
         resourceColor = subrescolor;
      }
    }
//   } else {
//     kdDebug(5850) << "resourceColor: Calendar is not a CalendarResources" <<endl;
  }
  return resourceColor;
}
コード例 #3
0
QString KOHelper::resourceLabel(KCal::Calendar * calendar, KCal::Incidence * incidence)
{
  KCal::CalendarResources *calendarResource = dynamic_cast<KCal::CalendarResources*>( calendar );
  if ( !calendarResource || ! incidence )
    return QString();

  KCal::ResourceCalendar *resourceCalendar = calendarResource->resource( incidence );
  if( resourceCalendar ) {
    if ( !resourceCalendar->subresources().isEmpty() ) {
      QString subRes = resourceCalendar->subresourceIdentifier( incidence );
      if ( subRes.isEmpty() )
        return resourceCalendar->resourceName();
      return resourceCalendar->labelForSubresource( subRes );
    }
    return resourceCalendar->resourceName();
  }

  return QString();
}
コード例 #4
0
void LockerThread::run()
{
  KCal::CalendarResources         *calendars = 0;
  KCal::ResourceCalendar          *calendar  = 0;
  KCal::CalendarResources::Ticket *lock      = 0;

  calendars = new KCal::CalendarResources( QString::fromLatin1( "UTC" ) );
  calendar  = new KCal::ResourceLocal( m_icsfile );
  lock      = calendars->requestSaveTicket( calendar );
  if ( lock )
  {
    m_gotlock = true;
    calendars->releaseSaveTicket( lock );
  }
  else
  {
    m_gotlock = false;
  }

  delete calendar;
  delete calendars;
}
コード例 #5
0
int main( int argc, char **argv )
{
  KAboutData aboutData( "soapdebug", 0, ki18n("Groupwise Soap Debug"), "0.1" );
  aboutData.addAuthor( ki18n("Cornelius Schumacher"), KLocalizedString(), "*****@*****.**" );

  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add("s");
  options.add("server <hostname>", ki18n("Server"));
  options.add("u");
  options.add("user <string>", ki18n("User"));
  options.add("p");
  options.add("password <string>", ki18n("Password"));
  options.add("f");
  options.add("freebusy-user <string>", ki18n("Free/Busy user name"));
  options.add("addressbook-id <string>", ki18n("Address book identifier"));
  KCmdLineArgs::addCmdLineOptions( options );

  KApplication app;

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  QString user = args->getOption( "user" );
  QString pass = args->getOption( "password" );
  QString url = args->getOption( "server" );

#if 1
  if ( user.isEmpty() ) {
    kError() <<"Need user.";
    return 1; 
  }
  if ( pass.isEmpty() ) {
    kError() <<"Need password.";
    return 1; 
  }
  if ( url.isEmpty() ) {
    kError() <<"Need server.";
    return 1; 
  }
#endif
  KDateTime::Spec spec = KDateTime::Spec::LocalZone();
  GroupwiseServer server( url, user, pass, spec, 0 );

#if 1
  if ( !server.login() ) {
    kError() <<"Unable to login to server" << url;
    return 1;
  }
#endif

#if 0
  server.dumpData();
#endif

#if 0
  server.getCategoryList();
#endif

#if 0
  server.dumpFolderList();
#endif

#if 0
  QString fbUser = args->getOption( "freebusy-user" );
  if ( fbUser.isEmpty() ) {
    kError() <<"Need user for which the freebusy data should be retrieved.";
  } else {
    KCal::FreeBusy *fb = new KCal::FreeBusy;

    server.readFreeBusy( "user1",
      QDate( 2004, 9, 1 ), QDate( 2004, 10, 31 ), fb );
  }
#endif

#if 0
  KTemporaryFile temp;
  temp.setautoRemove(false);
  temp.open();
  KCal::ResourceLocal resource( temp.fileName() );
  resource.setActive( true );
  KCal::CalendarResources calendar;
  calendar.resourceManager()->add( &resource );
  kDebug() <<"Login";

  if ( !server.login() ) {
    kDebug() <<"Unable to login.";
  } else {
    kDebug() <<"Read calendar";
    if ( !server.readCalendarSynchronous( &resource ) ) {
      kDebug() <<"Unable to read calendar data.";
    }
    kDebug() <<"Logout";
    server.logout();
  }
  KCal::ICalFormat format;

  QString ical = format.toString( &calendar );

  kDebug() <<"ICALENDAR:" << ical;
#endif

#if 0
  QString id = args->getOption( "addressbook-id" );

  kDebug() <<"ADDRESSBOOK ID:" << id;

  QStringList ids;
  ids.append( id );

  KABC::ResourceMemory resource;

  kDebug() <<"Login";
  if ( !server.login() ) {
    kError() <<"Unable to login.";
  } else {
    kDebug() <<"Read Addressbook";
    if ( !server.readAddressBooksSynchronous( ids, &resource ) ) {
      kError() <<"Unable to read addressbook data.";
    }
    kDebug() <<"Logout";
    server.logout();
  }

  KABC::Addressee::List addressees;
  KABC::Resource::Iterator it2;
  for( it2 = resource.begin(); it2 != resource.end(); ++it2 ) {
    kDebug() <<"ADDRESSEE:" << (*it2).fullEmail();
    addressees.append( *it2 );
  }
#endif

#if 0    
  server.getDelta();
#endif

  server.logout();

  return 0;
}