Changeset 19916 in project


Ignore:
Timestamp:
08/31/10 11:43:42 (10 years ago)
Author:
felix winkelmann
Message:

removed dbus stuff from main egg

Location:
release/4/qt/branches/qt-new
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/qt/branches/qt-new/main.cpp

    r17923 r19916  
    55#include <QGLWidget>
    66#include <QtCore>
    7 #include <QtDBus>
    87#include <QHttp>
    98#include <chicken.h>
     
    218217#define qtaction          QAction *
    219218#define qtvariantlist     QVariantList *
    220 #define qtdbusconnection  QDBusConnection *
    221219#define qtvariantlist     QVariantList *
    222220#define qthttp            QHttp *
     
    279277void qt_variant_list_discard_front(QVariantList *l) { l->pop_front(); }
    280278int qt_variant_list_length(QVariantList *l) { return l->length(); }
    281 
    282 QDBusConnection *qt_dbus_session_bus()
    283 { return new QDBusConnection(QDBusConnection::sessionBus()); }
    284 QDBusConnection *qt_dbus_system_bus()
    285 { return new QDBusConnection(QDBusConnection::systemBus()); }
    286 void qt_destroy_dbus_connection(QDBusConnection *c) { delete c; }
    287 
    288 ___bool qt_c_dbus_connect(QDBusConnection *c,
    289                         char *service, char *object,
    290                         char *interface, char *signal,
    291                         QObject *w2, char *slot)
    292 { return c->connect(service, object, interface, signal, w2, slot); }
    293 ___bool qt_dbus_disconnect(QDBusConnection *c,
    294                              char *service, char *object,
    295                            char *interface, char *signal,
    296                            QObject *w2, char *slot)
    297 { return c->disconnect(service, object, interface, signal, w2, slot); }
    298 void qt_c_dbus_list_names(QDBusConnection *bus, QVariantList* l)
    299 {
    300   QStringList serviceNames = bus->interface()->registeredServiceNames();
    301   for(int i = 0; i < serviceNames.length(); ++i)
    302     *l << *(new QString(serviceNames.at(i)));
    303 }
    304 ___bool qt_c_dbus_send_signal(QDBusConnection *bus, char *object,
    305                             char *interface, char *signal, QVariantList* l)
    306 {
    307   QDBusMessage message = QDBusMessage::createSignal(object, interface, signal);
    308   message.setArguments(*l);
    309   return bus->send(message);
    310 }
    311 
    312 ___bool qt_dbus_register_object(QDBusConnection *bus, char *path, QObject *obj)
    313 { return bus->registerObject(path, obj, QDBusConnection::ExportAllSlots); }
    314 void qt_dbus_unregister_object(QDBusConnection *bus, char *path)
    315 { bus->unregisterObject(path); }
    316 ___bool qt_dbus_method_call(QDBusConnection *bus, char *service, char *path,
    317                             char *interface, char *method, QVariantList* l)
    318 {
    319   QDBusMessage msg = QDBusMessage::createMethodCall(service, path, interface, method);
    320   msg.setArguments(*l);
    321 
    322   QDBusMessage reply = bus->call(msg, QDBus::BlockWithGui);
    323   l->clear();
    324   l->push_back((int)reply.type());
    325   if(QDBusMessage::ErrorMessage == reply.type())
    326     l->push_back(reply.errorName());
    327   if(reply.arguments().length() && reply.arguments().at(0).isValid())
    328     l->append(reply.arguments());
    329   return (reply.type() != QDBusMessage::ErrorMessage
    330           && reply.type() != QDBusMessage::InvalidMessage);
    331 }
    332 
    333 ___bool qt_dbus_method_call_with_callback(QDBusConnection *bus, char *service, char *path,
    334                                                   char *interface, char *method, QVariantList *l,
    335                                                   QObject *obj, char *slot)
    336 {
    337   QDBusMessage msg = QDBusMessage::createMethodCall(service, path, interface, method);
    338   msg.setArguments(*l);
    339   return bus->callWithCallback(msg, obj, slot);
    340 }
    341 
    342 
    343 ___bool qt_dbus_register_service(QDBusConnection *bus, char *service)
    344 { return bus->interface()->registerService(service); }
    345 ___bool qt_dbus_unregister_service(QDBusConnection *bus, char *service)
    346 { return bus->unregisterService(service); }
    347279
    348280___bool qt_invokemethod(QObject *o, char *signal, QVariantList *arguments)
  • release/4/qt/branches/qt-new/prototypes.h

    r17923 r19916  
    8383___bool qt_invokemethod(qtobject o, char *signal, qtvariantlist arguments);
    8484void qt_variant_list_discard_front(qtvariantlist l);
    85 qtdbusconnection qt_dbus_session_bus();
    86 qtdbusconnection qt_dbus_system_bus();
    87 void qt_destroy_dbus_connection(qtdbusconnection c);
    88 ___bool qt_c_dbus_connect(qtdbusconnection c,
    89                         char *service, char *object,
    90                         char *interface, char *signal,
    91                         qtobject w2, char *slot);
    92 ___bool qt_dbus_disconnect(qtdbusconnection c,
    93                            char *service, char *object,
    94                            char *interface, char *signal,
    95                            qtobject w2, char *slot);
    96 void qt_c_dbus_list_names(qtdbusconnection c, qtvariantlist l);
    97 ___bool qt_c_dbus_send_signal(qtdbusconnection bus, char *object,
    98                             char *interface, char *signal, qtvariantlist l);
    99 ___bool qt_dbus_register_object(qtdbusconnection bus, char *path, qtobject obj);
    100 void qt_dbus_unregister_object(qtdbusconnection bus, char *path);
    101 ___bool qt_dbus_method_call(qtdbusconnection bus, char *service, char *path,
    102                             char *interface, char *method, qtvariantlist l);
    103 ___bool qt_dbus_method_call_with_callback(qtdbusconnection bus, char *service, char *path,
    104                                           char *interface, char *method, qtvariantlist l,
    105                                           qtobject obj, char *slot);
    106 ___bool qt_dbus_register_service(qtdbusconnection bus, char *service);
    107 ___bool qt_dbus_unregister_service(qtdbusconnection bus, char *service);
    10885
    10986qthttp qt_make_http();
  • release/4/qt/branches/qt-new/qt-base.scm

    r19437 r19916  
    2424            qt:emit-signal qt:invoke-method
    2525            qt:variant-list-discard-front
    26             qt:session-bus qt:system-bus qt:dbus-connect
    27             qt:dbus-list-names qt:dbus-send-signal
    28             qt:dbus-register-method qt:dbus-call
    29             qt:dbus-call-with-callback
    30             qt:dbus-register-service qt:dbus-unregister-service
    3126            qt:http-read-string qt:http-get qt:make-http
    3227            qt:destroy-http qt:http-set-host qt:http-read-bytes
     
    3631            qt:pointer->sound qt:pointer->text-edit
    3732            qt:pointer->action qt:pointer->variant-list
    38             qt:pointer->dbus-connection qt:pointer->http
     33            qt:pointer->http
    3934            )
    4035
     
    6257(define <qt-action> (% <qt-object> (class 'qt-action)))
    6358(define <qt-variant-list> (% <qt> (class 'qt-variant-list)))
    64 (define <qt-dbus-connection> (% <qt> (class 'qt-dbus-connection)))
    6559(define <qt-http> (% <qt> (class 'qt-http)))
    6660
     
    7670(define (qt:pointer->action p) (and p (% <qt-action> (pointer p))))
    7771(define (qt:pointer->variant-list p) (and p (% <qt-variant-list> (pointer p))))
    78 (define (qt:pointer->dbus-connection p) (and p (% <qt-dbus-connection> (pointer p))))
    7972(define (qt:pointer->http p) (and p (% <qt-http> (pointer p))))
    8073
     
    9285___declare(type, "qtaction;(c-pointer \"QAction\");qt:->pointer;qt:pointer->action")
    9386___declare(type, "qtvariantlist;(c-pointer \"QVariantList\");qt:->pointer;qt:pointer->variant-list")
    94 ___declare(type, "qtdbusconnection;(c-pointer \"QDBusConnection\");qt:->pointer;qt:pointer->dbus-connection")
    9587___declare(type, "qthttp;(c-pointer \"QHttp\");qt:->pointer;qt:pointer->http")
    9688<#
     
    10193#include <QGLWidget>
    10294#include <QtCore>
    103 #include <QtDBus>
    10495#include <QHttp>
    105 #include <chicken.h>
    106 #include <assert.h>
    10796<#
    10897
     
    137126  (map (lambda (n) (qt:variant-list-remove-front l))
    138127       (iota (qt:variant-list-length l))))
    139 
    140 (define (qt:session-bus)
    141   (let ((b (qt:dbus-session-bus)))
    142     (set-finalizer! b qt:destroy-dbus-connection)
    143     b))
    144 (define (qt:system-bus)
    145   (let ((b (qt:dbus-system-bus)))
    146     (set-finalizer! b qt:destroy-dbus-connection)
    147     b))
    148 
    149 (define (qt:dbus-connect bus service object interface signal to
    150                          #!optional (slot signal))
    151   (let ((dest (if (procedure? to)
    152                   (qt:dynamicreceiver (->string (gensym "qt:dynamic-receiver"))
    153                                       (string->slot slot)
    154                                       to)
    155                   to)))
    156     (if (qt:c-dbus-connect bus service object interface signal dest (string->slot slot))
    157         (lambda ()
    158           (if (procedure? to)
    159               (qt:deleteobject dest)
    160               (qt:dbus-disconnect bus service object interface signal dest (string->slot slot))))
    161         (begin (when (procedure? to) (qt:deleteobject dest)) #f))))
    162 
    163 (define (qt:dbus-send-signal bus object interface signal . arguments)
    164   (let ((v (qt:list->variant-list arguments)))
    165     (qt:c-dbus-send-signal bus object interface signal v)))
    166 
    167 (define (qt:dbus-list-names bus)
    168   (let ((v (qt:make-variant-list)))
    169     (qt:c-dbus-list-names bus v)
    170     (qt:variant-list->list v)))
    171 
    172 (define (qt:dbus-register-method bus path f name)
    173   (let ((target (qt:dynamicreceiver (->string (gensym "qt:dynamic-receiver"))
    174                                     (string->slot name)
    175                                     f)))
    176     (if (qt:dbus-register-object bus path target)
    177         (lambda () (qt:deleteobject target))
    178         (begin (qt:deleteobject target) #f))))
    179 
    180 ;;; TODO Need blocking & timeouts, blocking with GUI & timeouts, slots
    181 ;;; Blocking with gui is implemented for now because we use signal/slots
    182 ;;; so we can service dbus calls to ourselves
    183 (define (qt:dbus-call bus service path interface method . arguments)
    184   (let ((v (qt:list->variant-list arguments)))
    185     ((foreign-safe-lambda bool "qt_dbus_method_call"
    186        qtdbusconnection c-string c-string c-string c-string qtvariantlist)
    187      bus service path interface method v)
    188     (qt:variant-list->list v)))
    189 
    190 (define (qt:dbus-call-with-callback bus service path interface method fun slot . arguments)
    191   (letrec ((v (qt:list->variant-list arguments))
    192            (target (qt:dynamicreceiver (->string (gensym "qt:dynamic-receiver"))
    193                                        (string->slot slot)
    194                                        (lambda a (qt:deleteobject target) (apply fun a)))))
    195     ((foreign-safe-lambda bool "qt_dbus_method_call_with_callback"
    196        qtdbusconnection c-string c-string c-string c-string qtvariantlist
    197        qtobject c-string)
    198      bus service path interface method v target (string->slot slot))))
    199128
    200129
Note: See TracChangeset for help on using the changeset viewer.