~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to akonadi/resources/kolabproxy/kolabhandler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-07-10 06:34:50 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20090710063450-neojgew2fh0n3y0u
Tags: 4:4.2.96-0ubuntu1
* New upstream release
* Bump kde build-deps to 4.2.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (c) 2009 Andras Mantia <amantia@kde.org>
3
 
 
4
 
    This library is free software; you can redistribute it and/or modify it
5
 
    under the terms of the GNU Library General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or (at your
7
 
    option) any later version.
8
 
 
9
 
    This library is distributed in the hope that it will be useful, but WITHOUT
10
 
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
12
 
    License for more details.
13
 
 
14
 
    You should have received a copy of the GNU Library General Public License
15
 
    along with this library; see the file COPYING.LIB.  If not, write to the
16
 
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
 
    02110-1301, USA.
18
 
*/
19
 
#include "kolabhandler.h"
20
 
#include "addressbookhandler.h"
21
 
#include "calendarhandler.h"
22
 
#include "taskshandler.h"
23
 
#include "journalhandler.h"
24
 
 
25
 
KolabHandler::KolabHandler()
26
 
{
27
 
}
28
 
 
29
 
KolabHandler *KolabHandler::createHandler(const QByteArray& type)
30
 
{
31
 
  if (type ==  "contact.default" || type ==  "contact") {
32
 
    return new AddressBookHandler();
33
 
  } else if (type ==  "event.default" || type ==  "event") {
34
 
    return new CalendarHandler();
35
 
  } else if (type ==  "task.default" || type ==  "task") {
36
 
    return new TasksHandler();
37
 
  } else if (type ==  "journal.default" || type ==  "journal") {
38
 
    return new JournalHandler();
39
 
  } else if (type ==  "note.default" || type ==  "note") {
40
 
    JournalHandler *handler =  new JournalHandler();
41
 
    handler->setMimeType("application/x-vnd.kolab.note");
42
 
    return handler;
43
 
  } else {
44
 
    return 0L;
45
 
  }
46
 
}
47
 
 
48
 
 
49
 
KolabHandler::~KolabHandler()
50
 
{
51
 
}
52
 
 
53
 
QByteArray KolabHandler::mimeType() const
54
 
{
55
 
  return m_mimeType;
56
 
}
57
 
 
58
 
void KolabHandler::setMimeType(const QByteArray &type)
59
 
{
60
 
  m_mimeType = type;
61
 
}
62
 
 
63
 
 
64
 
KMime::Content* KolabHandler::findContentByType(MessagePtr data, const QByteArray &type)
65
 
{
66
 
  KMime::Content::List list = data->contents();
67
 
  Q_FOREACH(KMime::Content *c, list)
68
 
  {
69
 
    if (c->contentType()->mimeType() ==  type)
70
 
      return c;
71
 
  }
72
 
  return 0L;
73
 
 
74
 
}
75
 
 
76
 
KMime::Content* KolabHandler::findContentByName(MessagePtr data, const QString &name, QByteArray &type)
77
 
{
78
 
  KMime::Content::List list = data->contents();
79
 
  Q_FOREACH(KMime::Content *c, list)
80
 
  {
81
 
    if (c->contentType()->name() == name)
82
 
      type = QByteArray(c->contentType()->type());
83
 
    return c;
84
 
  }
85
 
  return 0L;
86
 
 
87
 
}
88