Changeset 561 for trunk/src/dbus/qdbusconnection.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/dbus/qdbusconnection.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtDBus module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 558 558 const QString &name, QObject *receiver, const char *slot) 559 559 { 560 return connect(service, path, interface, name, QString(), receiver, slot); 561 } 562 563 /*! 564 Disconnects the signal specified by the \a service, \a path, \a interface and \a name parameters from 565 the slot \a slot in object \a receiver. The arguments \a service and \a path can be empty, 566 denoting a disconnection from all signals of the (\a interface, \a name) pair, from all remote 567 applications. 568 569 Returns true if the disconnection was successful. 570 */ 571 bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, 572 const QString &name, QObject *receiver, const char *slot) 573 { 574 return disconnect(service, path, interface, name, QString(), receiver, slot); 560 return connect(service, path, interface, name, QStringList(), QString(), receiver, slot); 575 561 } 576 562 … … 579 565 580 566 Connects the signal to the slot \a slot in object \a 581 receiver. Unlike the otherconnect() overload, this function567 receiver. Unlike the previous connect() overload, this function 582 568 allows one to specify the parameter signature to be connected 583 569 using the \a signature variable. The function will then verify … … 585 571 slot and return false otherwise. 586 572 573 Returns true if the connection was successful. 574 587 575 \note This function verifies that the signal signature matches the 588 576 slot's parameters, but it does not verify that the actual … … 594 582 QObject *receiver, const char *slot) 595 583 { 584 return connect(service, path, interface, name, QStringList(), signature, receiver, slot); 585 } 586 587 /*! 588 \overload 589 \since 4.6 590 591 Connects the signal to the slot \a slot in object \a 592 receiver. Unlike the previous connect() overload, this function 593 allows one to specify the parameter signature to be connected 594 using the \a signature variable. The function will then verify 595 that this signature can be delivered to the slot specified by \a 596 slot and return false otherwise. 597 598 The \a argumentMatch parameter lists the string parameters to be matched, 599 in sequential order. Note that, to match an empty string, you need to 600 pass a QString that is empty but not null (i.e., QString("")). A null 601 QString skips matching at that position. 602 603 Returns true if the connection was successful. 604 605 \note This function verifies that the signal signature matches the 606 slot's parameters, but it does not verify that the actual 607 signal exists with the given signature in the remote 608 service. 609 */ 610 bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface, 611 const QString &name, const QStringList &argumentMatch, const QString &signature, 612 QObject *receiver, const char *slot) 613 { 614 596 615 if (!receiver || !slot || !d || !d->connection) 597 616 return false; … … 601 620 return false; 602 621 603 // check the slot604 QDBusConnectionPrivate::SignalHook hook;605 QString key;606 QString name2 = name;607 if (name2.isNull())608 name2.detach();609 610 QString owner = d->getNameOwner(service); // we don't care if the owner is empty611 hook.signature = signature; // it might get started later612 if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))613 return false; // don't connect614 615 // avoid duplicating:616 622 QDBusWriteLocker locker(ConnectAction, d); 617 QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key); 618 QDBusConnectionPrivate::SignalHookHash::ConstIterator end = d->signalHooks.constEnd(); 619 for ( ; it != end && it.key() == key; ++it) { 620 const QDBusConnectionPrivate::SignalHook &entry = it.value(); 621 if (entry.service == hook.service && 622 entry.owner == hook.owner && 623 entry.path == hook.path && 624 entry.signature == hook.signature && 625 entry.obj == hook.obj && 626 entry.midx == hook.midx) { 627 // no need to compare the parameters if it's the same slot 628 return true; // already there 629 } 630 } 631 632 d->connectSignal(key, hook); 633 return true; 623 return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); 624 } 625 626 /*! 627 Disconnects the signal specified by the \a service, \a path, \a interface 628 and \a name parameters from the slot \a slot in object \a receiver. The 629 arguments must be the same as passed to the connect() function. 630 631 Returns true if the disconnection was successful. 632 */ 633 bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface, 634 const QString &name, QObject *receiver, const char *slot) 635 { 636 return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot); 634 637 } 635 638 … … 637 640 \overload 638 641 639 Disconnects the signal from the slot \a slot in object\a640 receiver. Unlike the other disconnect() overload, this function641 allows one to specify the parameter signature to be disconnected642 using the \a signature variable. The function will then verify643 that this signature is connected to the slot specified by \a slot 644 and return false otherwise.642 Disconnects the signal specified by the \a service, \a path, \a 643 interface, \a name, and \a signature parameters from the slot \a slot in 644 object \a receiver. The arguments must be the same as passed to the 645 connect() function. 646 647 Returns true if the disconnection was successful. 645 648 */ 646 649 bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, 647 650 const QString &name, const QString &signature, 651 QObject *receiver, const char *slot) 652 { 653 return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot); 654 } 655 656 /*! 657 \overload 658 \since 4.6 659 660 Disconnects the signal specified by the \a service, \a path, \a 661 interface, \a name, \a argumentMatch, and \a signature parameters from 662 the slot \a slot in object \a receiver. The arguments must be the same as 663 passed to the connect() function. 664 665 Returns true if the disconnection was successful. 666 */ 667 bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface, 668 const QString &name, const QStringList &argumentMatch, const QString &signature, 648 669 QObject *receiver, const char *slot) 649 670 { … … 655 676 return false; 656 677 657 // check the slot658 QDBusConnectionPrivate::SignalHook hook;659 QString key;660 QString name2 = name;661 if (name2.isNull())662 name2.detach();663 664 QString owner = d->getNameOwner(service); // we don't care of owner is empty665 hook.signature = signature;666 if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))667 return false; // don't disconnect668 669 // avoid duplicating:670 678 QDBusWriteLocker locker(DisconnectAction, d); 671 QDBusConnectionPrivate::SignalHookHash::Iterator it = d->signalHooks.find(key); 672 QDBusConnectionPrivate::SignalHookHash::Iterator end = d->signalHooks.end(); 673 for ( ; it != end && it.key() == key; ++it) { 674 const QDBusConnectionPrivate::SignalHook &entry = it.value(); 675 if (entry.service == hook.service && 676 entry.owner == hook.owner && 677 entry.path == hook.path && 678 entry.signature == hook.signature && 679 entry.obj == hook.obj && 680 entry.midx == hook.midx) { 681 // no need to compare the parameters if it's the same slot 682 d->disconnectSignal(it); 683 return true; // it was there 684 } 685 } 686 687 // the slot was not found 688 return false; 679 return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot); 689 680 } 690 681 … … 974 965 975 966 /*! 967 \nonreentrant 968 976 969 Returns the connection that sent the signal, if called in a slot activated 977 970 by QDBus; otherwise it returns 0. 971 972 \note Please avoid this function. This function is not thread-safe, so if 973 there's any other thread delivering a D-Bus call, this function may return 974 the wrong connection. In new code, please use QDBusContext::connection() 975 (see that class for a description on how to use it). 978 976 */ 979 977 QDBusConnection QDBusConnection::sender() … … 1006 1004 ref.deref(); // busService has increased the refcounting to us 1007 1005 // avoid cyclic refcounting 1008 // if (mode != PeerMode)1009 QObject::connect(busService, SIGNAL(serviceOwnerChanged(QString,QString,QString)),1010 this, SIGNAL(serviceOwnerChanged(QString,QString,QString)));1011 1006 1012 1007 QObject::connect(this, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)), 1013 1008 busService, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)), 1014 1009 Qt::QueuedConnection); 1015 1016 1010 } 1017 1011
Note:
See TracChangeset
for help on using the changeset viewer.