Logo Search packages:      
Sourcecode: kmess version File versions  Download package

void AddressBookService::parseSecureResult ( SoapMessage message  )  [private, virtual]

Parse the result of the response from the server.

We can parse two different soap replies: 1) the membership lists that contains the lists of contacts and them respective roles: Allow, Block, Reverse, Pending. 2) the address book list that contains the groups and the contacts with them friendlyname, id etc..

Parameters:
message the SOAP response message.
See also:
PassportLoginService::parseSoapResult().

Reimplemented from PassportLoginService.

Definition at line 836 of file addressbookservice.cpp.

References SoapMessage::getBody(), SoapMessage::getData(), retrieveMembershipLists(), MessageData::type, and MessageData::value.

{
  QDomElement body( message->getBody().toElement() );
  QString     resultName( body.localName() );

  if( ! body.firstChildElement( "FindMembershipResponse" ).isNull() )
  {
    parseMembershipLists( body );
    return;
  }
  else if( ! body.firstChildElement( "ABFindAllResponse" ).isNull() )
  {
    parseAddressBook( body );
    return;
  }
  else if( ! body.firstChildElement( "ABContactUpdateResponse" ).isNull() )
  {
    // Updated a contact's info
    return;
  }
  else if( ! body.firstChildElement( "DeleteMemberResponse" ).isNull() )
  {
    // Contact removed from Membership list from selected Role
    return;
  }
  else if( ! body.firstChildElement( "ABAddResponse" ).isNull() )
  {
    // New address book was created: proceed with it
#ifdef KMESSDEBUG_ADDRESSBOOKSERVICE
    kDebug() << "Address book successfully created: retrying to obtain membership lists.";
#endif
    retrieveMembershipLists();
    return;
  }

  // Get the message's data
  MessageData data( message->getData() );

  if( data.type == "ContactAdd" )
  {
    // A contact was added to the AB

          QStringList  info     ( data.value.toStringList() );
    const QString&     handle   ( info.takeFirst() );
    const QStringList& groupsId ( info );
    const QString&     contactId( body.elementsByTagName( "guid" ).item(0).toElement().text() );

    // If the contact is valid, signal that the contact was added to AB
    if( ! contactId.isEmpty() && ! handle.isEmpty() )
    {
      emit contactAdded( handle, contactId, groupsId );
    }
  }
  else if( data.type == "ContactDelete" )
  {
    // A contact was deleted from the AB

    const QString& contactId( data.value.toString() );

    if( ! contactId.isEmpty() )
    {
      emit contactDeleted( contactId );
    }
  }
  else if( data.type == "ContactBlock" || data.type == "ContactUnblock" )
  {
    // A contact was added to the Membership list in a certain Role

    const QStringList& info  ( data.value.toStringList() );
    const QString&     handle( info.value( 0 ) );
    const QString&     role  ( info.value( 1 ) );

    if( role == "BL" )
    {
      emit contactBlocked( handle );
    }
    else if( role == "AL" )
    {
      emit contactUnblocked( handle );
    }
  }
  else if( data.type == "ContactAddToGroup" )
  {
    // A contact was added to a group

    const QString& groupId  ( data.value.toString() );
    const QString& contactId( body.elementsByTagName( "guid" ).item(0).toElement().text() );

    if( ! contactId.isEmpty() && ! groupId.isEmpty() )
    {
      emit contactAddedToGroup( contactId, groupId );
    }
  }
  else if( data.type == "ContactDeleteFromGroup" )
  {
    // A contact was removed from a group

    const QStringList& info     ( data.value.toStringList() );
    const QString&     contactId( info.value( 0 ) );
    const QString&     groupId  ( info.value( 1 ) );

    if( ! contactId.isEmpty() && ! groupId.isEmpty() )
    {
      emit contactDeletedFromGroup( contactId, groupId );
    }
  }
  else if( data.type == "GroupAdd" )
  {
    // A group was added
    const QString& name   ( data.value.toString() );
    const QString& groupId( body.elementsByTagName( "guid" ).item(0).toElement().text() );

    if( ! groupId.isEmpty() && ! name.isEmpty() )
    {
      emit groupAdded( groupId, name );
    }
  }
  else if( data.type == "GroupDelete" )
  {
    // A group was removed
    const QString& groupId( data.value.toString() );

    if( ! groupId.isEmpty() )
    {
      emit groupDeleted( groupId );
    }
  }
  else if( data.type == "GroupRename" )
  {
    // A group was renamed
    const QStringList& info   ( data.value.toStringList() );
    const QString&     groupId( info.value( 0 ) );
    const QString&     name   ( info.value( 1 ) );

    if( ! groupId.isEmpty() && ! name.isEmpty() )
    {
      emit groupRenamed( groupId, name );
    }
  }
  else
  {
    kWarning() << "Response data not recognized:" << data.type;
  }
}


Generated by  Doxygen 1.6.0   Back to index