Home | History | Annotate | Download | only in xmpp
      1 /*
      2  *  Copyright 2011 The WebRTC Project Authors. All rights reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_LIBJINGLE_XMPP_MUCROOMLOOKUPTASK_H_
     12 #define WEBRTC_LIBJINGLE_XMPP_MUCROOMLOOKUPTASK_H_
     13 
     14 #include <string>
     15 #include "webrtc/libjingle/xmpp/iqtask.h"
     16 
     17 namespace buzz {
     18 
     19 struct MucRoomInfo {
     20   Jid jid;
     21   std::string name;
     22   std::string domain;
     23   std::string hangout_id;
     24 
     25   std::string full_name() const {
     26     return name + "@" + domain;
     27   }
     28 };
     29 
     30 class MucRoomLookupTask : public IqTask {
     31  public:
     32   enum IdType {
     33     ID_TYPE_CONVERSATION,
     34     ID_TYPE_HANGOUT
     35   };
     36 
     37   static MucRoomLookupTask*
     38       CreateLookupTaskForRoomName(XmppTaskParentInterface* parent,
     39                                   const Jid& lookup_server_jid,
     40                                   const std::string& room_name,
     41                                   const std::string& room_domain);
     42   static MucRoomLookupTask*
     43       CreateLookupTaskForRoomJid(XmppTaskParentInterface* parent,
     44                                  const Jid& lookup_server_jid,
     45                                  const Jid& room_jid);
     46   static MucRoomLookupTask*
     47       CreateLookupTaskForHangoutId(XmppTaskParentInterface* parent,
     48                                    const Jid& lookup_server_jid,
     49                                    const std::string& hangout_id);
     50   static MucRoomLookupTask*
     51       CreateLookupTaskForExternalId(XmppTaskParentInterface* parent,
     52                                     const Jid& lookup_server_jid,
     53                                     const std::string& external_id,
     54                                     const std::string& type);
     55 
     56   sigslot::signal2<MucRoomLookupTask*,
     57                    const MucRoomInfo&> SignalResult;
     58 
     59  protected:
     60   virtual void HandleResult(const XmlElement* element);
     61 
     62  private:
     63   MucRoomLookupTask(XmppTaskParentInterface* parent,
     64                     const Jid& lookup_server_jid,
     65                     XmlElement* query);
     66   static XmlElement* MakeNameQuery(const std::string& room_name,
     67                                    const std::string& room_domain);
     68   static XmlElement* MakeJidQuery(const Jid& room_jid);
     69   static XmlElement* MakeHangoutIdQuery(const std::string& hangout_id);
     70   static XmlElement* MakeExternalIdQuery(const std::string& external_id,
     71                                          const std::string& type);
     72 };
     73 
     74 }  // namespace buzz
     75 
     76 #endif  // WEBRTC_LIBJINGLE_XMPP_MUCROOMLOOKUPTASK_H_
     77