Results 1 to 3 of 3

Thread: Read map type from QDBusArgument

  1. #1
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Read map type from QDBusArgument

    Hi All,

    Here's the code attached

    Qt Code:
    1. QDBusInterface busInterface(
    2. DBUS_NETWORK_MANAGER_SYSYEM_SERVICE_NAME,
    3. m_strDhcp4Config.toAscii().data(),
    4. DBUS_NETWORK_MANAGER_SYSTEM_PROPERTIES_INTERFACE,
    5. QDBusConnection::systemBus());
    6.  
    7. QDBusReply< QVariantMap > result = busInterface.call(GETALL,
    8. DBUS_NETWORK_MANAGER_SYSTEM_ACTIVE_DHCP4CONFIG_INTERFACE);
    9.  
    10. if(result.isValid())
    11. {
    12. qDebug() << "Success";
    13. QVariantMap propertiesMap = result.value();
    14. QDBusArgument optionsArgument = qvariant_cast<QDBusArgument>(propertiesMap.value("Options"));
    15.  
    16. propertiesMap.clear();
    17. optionsArgument.beginArray();
    18.  
    19. while ( !optionsArgument.atEnd() ) {
    20. QVariant key;
    21. QVariant value;
    22. optionsArgument.beginMapEntry();
    23. optionsArgument >> key >> value;
    24. optionsArgument.endMapEntry();
    25. propertiesMap.insert( key, value);
    26. }
    27.  
    28. optionsArgument.endArray();
    29. }
    To copy to clipboard, switch view to plain text mode 

    I get this error "QDBusArgument: write from a read-only object" on the lines "optionsArgument.beginMapEntry();" and "optionsArgument.endMapEntry();"

    The response I'm looking to parse is
    "{u'broadcast_address': u'10.244.10.255',
    u'dhcp_lease_time': u'691200',
    u'dhcp_message_type': u'5',
    u'dhcp_rebinding_time': u'604800',
    u'dhcp_renewal_time': u'345600',
    u'dhcp_server_identifier': u'10.244.0.99',
    u'domain_name': u'persistent.co.in',
    u'domain_name_servers': u'10.244.0.100 10.244.0.99',
    u'expiry': u'1363079647',
    u'filename': u'smsboot\\x86\\wdsnbp.com',
    u'ip_address': u'10.244.10.232',
    u'netbios_name_servers': u'10.244.0.100',
    u'network_number': u'10.244.10.0',
    u'routers': u'10.244.10.1',
    u'subnet_mask': u'255.255.255.0'}"

    Kindly suggest how can I parse this value appropriately..
    Thanks,
    Volcano

  2. #2
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Read map type from QDBusArgument

    Minor error in code
    Qt Code:
    1. optionsArgument.beginMap();
    2. while ( !optionsArgument.atEnd() ) {
    3. QVariant key;
    4. QVariant value;
    5. optionsArgument.beginMapEntry();
    6. optionsArgument >> key >> value;
    7. optionsArgument.endMapEntry();
    8. propertiesMap.insert( key, value);
    9. }
    10. optionsArgument.endMap();
    To copy to clipboard, switch view to plain text mode 

    Kindly suggest me what should I do
    Regards,
    volcano

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Read map type from QDBusArgument

    While not directly related to your code, some general ideas:

    - have you evaluating using the Qt library for network manager instead of using D-Bus directly?
    - assuming network manager has the usual XML interface definition files, how about letting qdbusxml2cpp generate an interface class for you?

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 22nd May 2011, 21:31
  2. Replies: 13
    Last Post: 10th March 2011, 07:35
  3. Replies: 0
    Last Post: 19th February 2010, 16:33
  4. QSocketNotifier: Invalid socket 12 and type 'Read', disabling...
    By kunalnandi in forum General Programming
    Replies: 1
    Last Post: 24th September 2008, 18:09
  5. How to read encoding type in XML file
    By danbr in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2006, 08:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.