[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] libkcal amendments for email alarms
From:       David Jarvie <lists () astrojar ! org ! uk>
Date:       2002-11-28 12:44:16
[Download RAW message or body]

On Thursday 28 Nov 2002 8:02 am, Cornelius Schumacher wrote:
> On Thursday 28 November 2002 03:55, David Jarvie wrote:
> > Additionally, KAlarm needs to be able to store some stuff specific to it
> > in alarms, so I propose to add an X-KDE-KALARM-TYPE property to the
> > VALARM component in iCalendar.
>
> Please don't add Kalarm specific code to libkcal. If you really need custom
> parameters please implement a generic way to access these. Something like
> "setCustomParameter( const QString &app, const QString &key, const QString
> &value )".

I'm not sure about the 'app' parameter - is it necessary to have the 
application specified at all? When reading from the calendar, any custom 
properties which were set for other applications would be updated in the 
Alarm instance but would then simply be ignored by the client application. 
When writing to the calendar, custom property values in the Alarm instance 
should only exist for the client application, so no properties specific to 
other applications should be written. If you insist on a test for the 
application identity, presumably we would have to use 
kapp->aboutData()->appName() ?

Here is what I would propose in line with what you say. This shifts the 
interpretation of custom properties to the Alarm class.

In ICalFormatImpl::writeAlarm(), add:
=====================================
  // Add custom properties (if any)
  QMap<QCString, QString> custom = alarm->getCustomCalendarProperties();
  for (QMap<QCString, QString>::Iterator c = custom.begin();  c != 
custom.end();  ++c) {
    icalproperty *p = icalproperty_new_x(c.data().utf8());
    icalproperty_set_x_name(p,c.key());
    icalcomponent_add_property(a,p);
  }

In ICalFormatImpl::readAlarm(), in the get_next_property loop, add:
=====================================
  case ICAL_X_PROPERTY: {
    const char *value = icalproperty_get_value_as_string(p);
    ialarm->setCustomCalendarProperty(icalproperty_get_name(p), 
QString::fromUtf8(value));
    break;
  }

Add the following methods to Alarm:
===================================

void Alarm::setCustomCalendarProperty(const char *key, const QString &value)
{
  if (strcmp(key, "X-KDE-KALARM-TYPE") == 0)
    mKAlarmType = value;
}

QMap<QCString, QString> Alarm::getCustomCalendarProperties() const
{
  QMap<QCString, QString> properties;

  // KAlarm-specific stuff
  if (!mKAlarmType.isEmpty()) {
    properties["X-KDE-KALARM-TYPE"] = mKAlarmType;
  }
  return properties;
}


I think that we should also implement a similar mechanism for Incidence. 
Currently, calendar files all contain kpilot-specific properties which really 
shouldn't be there unless the calendar has been written by kpilot.

-- 
David Jarvie
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic