~kubuntu-members/korundum/4.11

« back to all changes in this revision

Viewing changes to kio/kiohandlers.cpp

  • Committer: Ian Monroe
  • Date: 2010-11-21 15:55:01 UTC
  • Revision ID: git-v1:c37670e4e3c59f5eb2ba112f5341a5e706217f6f
Split up Smoke into Qt and KDE directories. 
Move libsmoke stuff into the generator directory
Split up Ruby into qtruby and korundum directories

svn path=/trunk/KDE/kdebindings/ruby/; revision=1199320

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          kiohandlers.cpp  -  KIO specific marshallers
3
 
                             -------------------
4
 
    begin                : Mon Feb 8 2010
5
 
    copyright            : (C) 2008 by Jonathan Schmidt-Dominé
6
 
    email                : devel@the-user.org
7
 
 ***************************************************************************/
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 ***************************************************************************/
17
 
 
18
 
#include <ruby.h>
19
 
 
20
 
#include <qtruby.h>
21
 
#include <smokeruby.h>
22
 
#include <marshall_macros.h>
23
 
 
24
 
#include <kbookmarkmenu.h>
25
 
#include <QAction>
26
 
#include <QList>
27
 
#include <kfileitemdelegate.h>
28
 
#include <QAbstractItemModel>
29
 
#include <QNetworkCookie>
30
 
#include <KService>
31
 
 
32
 
// DEF_LIST_MARSHALLER( KIOKBookmarkMenuList, QList<KBookmarkMenu*>&, KBookmarkMenu )
33
 
DEF_LIST_MARSHALLER( QActionList, QList<QAction*>, QAction )
34
 
// DEF_LIST_MARSHALLER( QActionListRef, QList<QAction*>&, QAction )
35
 
// DEF_MAP_MARSHALLER( QStringMap, QMap<QString,QString>*, QString )
36
 
DEF_VALUELIST_MARSHALLER( KFileItemDelegeteInformationList, QList<KFileItemDelegate::Information>, KFileItemDelegate::Information )
37
 
DEF_VALUELIST_MARSHALLER( UIntList, QList<unsigned int>, unsigned int )
38
 
DEF_VALUELIST_MARSHALLER( QModelIndexList, QList<QModelIndex>, QModelIndex )
39
 
DEF_VALUELIST_MARSHALLER( QNetworkCookieList, QList<QNetworkCookie>, QNetworkCookie )
40
 
 
41
 
 
42
 
void marshall_KServiceList(Marshall *m) {
43
 
    switch(m->action()) {
44
 
        case Marshall::FromVALUE: 
45
 
        {
46
 
        }
47
 
        break;
48
 
        case Marshall::ToVALUE: 
49
 
        {
50
 
            KService::List *offerList = (KService::List*)m->item().s_voidp;
51
 
            if (!offerList) {
52
 
                *(m->var()) = Qnil;
53
 
                break;
54
 
            }
55
 
            
56
 
            VALUE av = rb_ary_new();
57
 
            
58
 
            for (   KService::List::Iterator it = offerList->begin();
59
 
            it != offerList->end();
60
 
            ++it ) 
61
 
            {
62
 
                KSharedPtr<KService> *ptr = new KSharedPtr<KService>(*it);
63
 
                KService * currentOffer = ptr->data();
64
 
                
65
 
                VALUE obj = getPointerObject(currentOffer);
66
 
                if (obj == Qnil) {
67
 
                    smokeruby_object  * o = ALLOC(smokeruby_object);
68
 
                    o->smoke = m->smoke();
69
 
                    o->classId = m->smoke()->idClass("KService").index;
70
 
                    o->ptr = currentOffer;
71
 
                    o->allocated = false;
72
 
                    obj = set_obj_info("KDE::Service", o);
73
 
                }
74
 
                rb_ary_push(av, obj);
75
 
            }
76
 
            
77
 
            *(m->var()) = av;       
78
 
            
79
 
            if (m->cleanup())
80
 
                delete offerList;
81
 
        }
82
 
        break;
83
 
        default:
84
 
            m->unsupported();
85
 
            break;
86
 
    }
87
 
}
88
 
 
89
 
 
90
 
TypeHandler KIO_handlers[] = {
91
 
// { "QList<KBookmarkMenu*>&", marshall_KIOKBookmarkMenuList },
92
 
{ "QList<KFileItemDelegate::Information>", marshall_KFileItemDelegeteInformationList },
93
 
{ "QList<KSharedPtr<KService>>", marshall_KServiceList },
94
 
{ "QList<QAction*>", marshall_QActionList },
95
 
// { "QList<QAction*>&", marshall_QActionListRef },
96
 
{ "QList<QModelIndex>", marshall_QModelIndexList },
97
 
{ "QList<QNetworkCookie>", marshall_QNetworkCookieList },
98
 
// { "QList<QPair<QString,QString>>", 0, Smoke::t_voidp|Smoke::tf_stack },     //267
99
 
// { "QList<QPair<QString,QString>>&", 0, Smoke::t_voidp|Smoke::tf_ref },      //268
100
 
// { "QList<QPair<QString,unsigned short>>", 0, Smoke::t_voidp|Smoke::tf_stack },      //269
101
 
{ "QList<unsigned int>", marshall_UIntList },
102
 
// { "QMap<QString,QString>*", marshall_QStringMap },
103
 
// { "QMap<int,QVariant>",  },
104
 
// { "QMenu*",  },
105
 
    { 0, 0 }
106
 
};