~ubuntu-branches/ubuntu/utopic/psi/utopic

« back to all changes in this revision

Viewing changes to third-party/qca/qca/src/qca_keystore.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2003-2007  Justin Karneges <justin@affinix.com>
 
2
 * Copyright (C) 2003-2008  Justin Karneges <justin@affinix.com>
3
3
 * Copyright (C) 2004,2005  Brad Hards <bradh@frogmouth.net>
4
4
 *
5
5
 * This library is free software; you can redistribute it and/or
14
14
 *
15
15
 * You should have received a copy of the GNU Lesser General Public
16
16
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
 * 02110-1301  USA
18
19
 *
19
20
 */
20
21
 
44
45
 
45
46
Provider::Context *getContext(const QString &type, Provider *p);
46
47
 
 
48
// from qca_plugin.cpp
 
49
QString truncate_log(const QString &in, int size);
 
50
 
47
51
/*
48
52
  How this stuff works:
49
53
 
121
125
        {
122
126
                self = this;
123
127
 
124
 
                qRegisterMetaType<QCA::KeyStoreEntry>("QCA::KeyStoreEntry");
125
 
                qRegisterMetaType< QList<QCA::KeyStoreEntry> >("QList<QCA::KeyStoreEntry>");
126
 
                qRegisterMetaType< QList<QCA::KeyStoreEntry::Type> >("QList<QCA::KeyStoreEntry::Type>");
 
128
                qRegisterMetaType<KeyStoreEntry>();
 
129
                qRegisterMetaType< QList<KeyStoreEntry> >();
 
130
                qRegisterMetaType< QList<KeyStoreEntry::Type> >();
 
131
                qRegisterMetaType<KeyBundle>();
 
132
                qRegisterMetaType<Certificate>();
 
133
                qRegisterMetaType<CRL>();
 
134
                qRegisterMetaType<PGPKey>();
127
135
 
128
136
                connect(this, SIGNAL(updated_p()), SLOT(updated_locked()), Qt::QueuedConnection);
129
137
 
265
273
                KeyStoreListContext *c = 0;
266
274
                int contextId = -1;
267
275
                m.lock();
268
 
                foreach(Item i, items)
 
276
                foreach(const Item &i, items)
269
277
                {
270
278
                        if(i.storeId == storeId)
271
279
                        {
312
320
                        return QString();
313
321
        }
314
322
 
 
323
        QString writeEntry(int trackerId, const QCA::KeyBundle &v)
 
324
        {
 
325
                int at = findItem(trackerId);
 
326
                if(at == -1)
 
327
                        return QString();
 
328
                Item &i = items[at];
 
329
 
 
330
                return i.owner->writeEntry(i.storeContextId, v);
 
331
        }
 
332
 
 
333
        QString writeEntry(int trackerId, const QCA::Certificate &v)
 
334
        {
 
335
                int at = findItem(trackerId);
 
336
                if(at == -1)
 
337
                        return QString();
 
338
                Item &i = items[at];
 
339
 
 
340
                return i.owner->writeEntry(i.storeContextId, v);
 
341
        }
 
342
 
 
343
        QString writeEntry(int trackerId, const QCA::CRL &v)
 
344
        {
 
345
                int at = findItem(trackerId);
 
346
                if(at == -1)
 
347
                        return QString();
 
348
                Item &i = items[at];
 
349
 
 
350
                return i.owner->writeEntry(i.storeContextId, v);
 
351
        }
 
352
 
 
353
        QString writeEntry(int trackerId, const QCA::PGPKey &v)
 
354
        {
 
355
                int at = findItem(trackerId);
 
356
                if(at == -1)
 
357
                        return QString();
 
358
                Item &i = items[at];
 
359
 
 
360
                return i.owner->writeEntry(i.storeContextId, v);
 
361
        }
 
362
 
315
363
        bool removeEntry(int trackerId, const QString &entryId)
316
364
        {
317
365
                int at = findItem(trackerId);
505
553
        {
506
554
                QMutexLocker locker(&m);
507
555
                dtext += str;
 
556
                dtext = truncate_log(dtext, 100000);
508
557
        }
509
558
 
510
559
        void ksl_storeUpdated(int id)
940
989
                                qVariantSetValue<CRL>(arg, wentry.crl);
941
990
                        else if(wentry.type == KeyStoreWriteEntry::TypePGPKey)
942
991
                                qVariantSetValue<PGPKey>(arg, wentry.pgpKey);
 
992
 
 
993
                        // note: each variant in the argument list is resolved
 
994
                        //   to its native type.  so even though it looks like
 
995
                        //   we're attempting to call a method named
 
996
                        //   writeEntry(QString,QVariant), we're actually
 
997
                        //   calling one of many possible methods, such as
 
998
                        //   writeEntry(QString,PGPKey) or
 
999
                        //   writeEntry(QString,Certificate), etc, depending
 
1000
                        //   on the type of object we put in the variant.
943
1001
                        entryId = trackercall("writeEntry", QVariantList() << trackerId << arg).toString();
944
1002
                }
945
1003
                else // RemoveEntry
1491
1549
                        }
1492
1550
                }
1493
1551
 
1494
 
                foreach(QString storeId, here)
 
1552
                foreach(const QString &storeId, here)
1495
1553
                {
1496
1554
                        emit q->keyStoreAvailable(storeId);
1497
1555
                        if(!self)