LCOV - code coverage report
Current view: top level - src/jami - conversation_interface.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 5 5 100.0 %
Date: 2024-05-02 09:40:27 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2013-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Adrien BĂ©raud <adrien.beraud@savoirfairelinux.com>
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, write to the Free Software
      18             :  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
      19             :  */
      20             : 
      21             : #ifndef LIBJAMI_CONVERSATIONI_H
      22             : #define LIBJAMI_CONVERSATIONI_H
      23             : 
      24             : #include "def.h"
      25             : 
      26             : #include <vector>
      27             : #include <map>
      28             : #include <string>
      29             : #include <list>
      30             : 
      31             : #include "jami.h"
      32             : 
      33             : namespace libjami {
      34             : 
      35             : struct SwarmMessage
      36             : {
      37             :     std::string id;
      38             :     std::string type;
      39             :     std::string linearizedParent;
      40             :     std::map<std::string, std::string> body;
      41             :     std::vector<std::map<std::string, std::string>> reactions;
      42             :     std::vector<std::map<std::string, std::string>> editions;
      43             :     std::map<std::string, int32_t> status;
      44             : 
      45       14842 :     void fromMapStringString(const std::map<std::string, std::string>& commit) {
      46       14842 :         id = commit.at("id");
      47       14842 :         type = commit.at("type");
      48       14842 :         body = commit; // TODO erase type/id?
      49       14841 :     }
      50             : };
      51             : 
      52             : // Conversation management
      53             : LIBJAMI_PUBLIC std::string startConversation(const std::string& accountId);
      54             : LIBJAMI_PUBLIC void acceptConversationRequest(const std::string& accountId,
      55             :                                               const std::string& conversationId);
      56             : LIBJAMI_PUBLIC void declineConversationRequest(const std::string& accountId,
      57             :                                                const std::string& conversationId);
      58             : LIBJAMI_PUBLIC bool removeConversation(const std::string& accountId,
      59             :                                        const std::string& conversationId);
      60             : LIBJAMI_PUBLIC std::vector<std::string> getConversations(const std::string& accountId);
      61             : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConversationRequests(
      62             :     const std::string& accountId);
      63             : 
      64             : // Calls
      65             : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getActiveCalls(
      66             :     const std::string& accountId, const std::string& conversationId);
      67             : 
      68             : // Conversation's infos management
      69             : LIBJAMI_PUBLIC void updateConversationInfos(const std::string& accountId,
      70             :                                             const std::string& conversationId,
      71             :                                             const std::map<std::string, std::string>& infos);
      72             : LIBJAMI_PUBLIC std::map<std::string, std::string> conversationInfos(
      73             :     const std::string& accountId, const std::string& conversationId);
      74             : LIBJAMI_PUBLIC void setConversationPreferences(const std::string& accountId,
      75             :                                                const std::string& conversationId,
      76             :                                                const std::map<std::string, std::string>& prefs);
      77             : LIBJAMI_PUBLIC std::map<std::string, std::string> getConversationPreferences(
      78             :     const std::string& accountId, const std::string& conversationId);
      79             : 
      80             : // Member management
      81             : LIBJAMI_PUBLIC void addConversationMember(const std::string& accountId,
      82             :                                           const std::string& conversationId,
      83             :                                           const std::string& contactUri);
      84             : LIBJAMI_PUBLIC void removeConversationMember(const std::string& accountId,
      85             :                                              const std::string& conversationId,
      86             :                                              const std::string& contactUri);
      87             : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConversationMembers(
      88             :     const std::string& accountId, const std::string& conversationId);
      89             : 
      90             : // Message send/load
      91             : LIBJAMI_PUBLIC void sendMessage(const std::string& accountId,
      92             :                                 const std::string& conversationId,
      93             :                                 const std::string& message,
      94             :                                 const std::string& replyTo,
      95             :                                 const int32_t& flag = 0);
      96             : LIBJAMI_PUBLIC uint32_t loadConversationMessages(const std::string& accountId,
      97             :                                                  const std::string& conversationId,
      98             :                                                  const std::string& fromMessage,
      99             :                                                  size_t n);
     100             : LIBJAMI_PUBLIC uint32_t loadConversation(const std::string& accountId,
     101             :                                                  const std::string& conversationId,
     102             :                                                  const std::string& fromMessage,
     103             :                                                  size_t n);
     104             : LIBJAMI_PUBLIC uint32_t loadConversationUntil(const std::string& accountId,
     105             :                                               const std::string& conversationId,
     106             :                                               const std::string& fromMessage,
     107             :                                               const std::string& toMessage);
     108             : LIBJAMI_PUBLIC uint32_t loadSwarmUntil(const std::string& accountId,
     109             :                                        const std::string& conversationId,
     110             :                                        const std::string& fromMessage,
     111             :                                        const std::string& toMessage);
     112             : LIBJAMI_PUBLIC uint32_t countInteractions(const std::string& accountId,
     113             :                                           const std::string& conversationId,
     114             :                                           const std::string& toId,
     115             :                                           const std::string& fromId,
     116             :                                           const std::string& authorUri);
     117             : LIBJAMI_PUBLIC void clearCache(const std::string& accountId, const std::string& conversationId);
     118             : LIBJAMI_PUBLIC uint32_t searchConversation(const std::string& accountId,
     119             :                                            const std::string& conversationId,
     120             :                                            const std::string& author,
     121             :                                            const std::string& lastId,
     122             :                                            const std::string& regexSearch,
     123             :                                            const std::string& type,
     124             :                                            const int64_t& after,
     125             :                                            const int64_t& before,
     126             :                                            const uint32_t& maxResult,
     127             :                                            const int32_t& flag);
     128             : LIBJAMI_PUBLIC void reloadConversationsAndRequests(const std::string& accountId);
     129             : 
     130             : struct LIBJAMI_PUBLIC ConversationSignal
     131             : {
     132             :     struct LIBJAMI_PUBLIC ConversationLoaded
     133             :     {
     134             :         constexpr static const char* name = "ConversationLoaded";
     135             :         using cb_type = void(uint32_t /* id */,
     136             :                              const std::string& /*accountId*/,
     137             :                              const std::string& /* conversationId */,
     138             :                              std::vector<std::map<std::string, std::string>> /*messages*/);
     139             :     };
     140             :     struct LIBJAMI_PUBLIC SwarmLoaded
     141             :     {
     142             :         constexpr static const char* name = "SwarmLoaded";
     143             :         using cb_type = void(uint32_t /* id */,
     144             :                              const std::string& /*accountId*/,
     145             :                              const std::string& /* conversationId */,
     146             :                              std::vector<SwarmMessage> /*messages*/);
     147             :     };
     148             :     struct LIBJAMI_PUBLIC MessagesFound
     149             :     {
     150             :         constexpr static const char* name = "MessagesFound";
     151             :         using cb_type = void(uint32_t /* id */,
     152             :                              const std::string& /*accountId*/,
     153             :                              const std::string& /* conversationId */,
     154             :                              std::vector<std::map<std::string, std::string>> /*messages*/);
     155             :     };
     156             :     struct LIBJAMI_PUBLIC MessageReceived
     157             :     {
     158             :         constexpr static const char* name = "MessageReceived";
     159             :         using cb_type = void(const std::string& /*accountId*/,
     160             :                              const std::string& /* conversationId */,
     161             :                              std::map<std::string, std::string> /*message*/);
     162             :     };
     163             :     struct LIBJAMI_PUBLIC SwarmMessageReceived
     164             :     {
     165             :         constexpr static const char* name = "SwarmMessageReceived";
     166             :         using cb_type = void(const std::string& /*accountId*/,
     167             :                              const std::string& /* conversationId */,
     168             :                              const SwarmMessage& /*message*/);
     169             :     };
     170             :     struct LIBJAMI_PUBLIC SwarmMessageUpdated
     171             :     {
     172             :         constexpr static const char* name = "SwarmMessageUpdated";
     173             :         using cb_type = void(const std::string& /*accountId*/,
     174             :                              const std::string& /* conversationId */,
     175             :                              const SwarmMessage& /*message*/);
     176             :     };
     177             :     struct LIBJAMI_PUBLIC ReactionAdded
     178             :     {
     179             :         constexpr static const char* name = "ReactionAdded";
     180             :         using cb_type = void(const std::string& /*accountId*/,
     181             :                              const std::string& /* conversationId */,
     182             :                              const std::string& /* messageId */,
     183             :                              std::map<std::string, std::string> /*reaction*/);
     184             :     };
     185             :     struct LIBJAMI_PUBLIC ReactionRemoved
     186             :     {
     187             :         constexpr static const char* name = "ReactionRemoved";
     188             :         using cb_type = void(const std::string& /*accountId*/,
     189             :                              const std::string& /* conversationId */,
     190             :                              const std::string& /* messageId */,
     191             :                              const std::string& /* reactionId */);
     192             :     };
     193             :     struct LIBJAMI_PUBLIC ConversationProfileUpdated
     194             :     {
     195             :         constexpr static const char* name = "ConversationProfileUpdated";
     196             :         using cb_type = void(const std::string& /*accountId*/,
     197             :                              const std::string& /* conversationId */,
     198             :                              std::map<std::string, std::string> /*profile*/);
     199             :     };
     200             :     struct LIBJAMI_PUBLIC ConversationRequestReceived
     201             :     {
     202             :         constexpr static const char* name = "ConversationRequestReceived";
     203             :         using cb_type = void(const std::string& /*accountId*/,
     204             :                              const std::string& /* conversationId */,
     205             :                              std::map<std::string, std::string> /*metadatas*/);
     206             :     };
     207             :     struct LIBJAMI_PUBLIC ConversationRequestDeclined
     208             :     {
     209             :         constexpr static const char* name = "ConversationRequestDeclined";
     210             :         using cb_type = void(const std::string& /*accountId*/,
     211             :                              const std::string& /* conversationId */);
     212             :     };
     213             :     struct LIBJAMI_PUBLIC ConversationReady
     214             :     {
     215             :         constexpr static const char* name = "ConversationReady";
     216             :         using cb_type = void(const std::string& /*accountId*/,
     217             :                              const std::string& /* conversationId */);
     218             :     };
     219             :     struct LIBJAMI_PUBLIC ConversationRemoved
     220             :     {
     221             :         constexpr static const char* name = "ConversationRemoved";
     222             :         using cb_type = void(const std::string& /*accountId*/,
     223             :                              const std::string& /* conversationId */);
     224             :     };
     225             :     struct LIBJAMI_PUBLIC ConversationMemberEvent
     226             :     {
     227             :         constexpr static const char* name = "ConversationMemberEvent";
     228             :         using cb_type = void(const std::string& /*accountId*/,
     229             :                              const std::string& /* conversationId */,
     230             :                              const std::string& /* memberUri */,
     231             :                              int /* event 0 = add, 1 = joins, 2 = leave, 3 = banned */);
     232             :     };
     233             : 
     234             :     struct LIBJAMI_PUBLIC ConversationSyncFinished
     235             :     {
     236             :         constexpr static const char* name = "ConversationSyncFinished";
     237             :         using cb_type = void(const std::string& /*accountId*/);
     238             :     };
     239             : 
     240             :     struct LIBJAMI_PUBLIC ConversationCloned
     241             :     {
     242             :         constexpr static const char* name = "ConversationCloned";
     243             :         using cb_type = void(const std::string& /*accountId*/);
     244             :     };
     245             : 
     246             :     struct LIBJAMI_PUBLIC CallConnectionRequest
     247             :     {
     248             :         constexpr static const char* name = "CallConnectionRequest";
     249             :         using cb_type = void(const std::string& /*accountId*/,
     250             :                              const std::string& /*peerId*/,
     251             :                              bool hasVideo);
     252             :     };
     253             : 
     254             :     struct LIBJAMI_PUBLIC OnConversationError
     255             :     {
     256             :         constexpr static const char* name = "OnConversationError";
     257             :         using cb_type = void(const std::string& /*accountId*/,
     258             :                              const std::string& /* conversationId */,
     259             :                              int code,
     260             :                              const std::string& what);
     261             :     };
     262             : 
     263             :     // Preferences
     264             :     struct LIBJAMI_PUBLIC ConversationPreferencesUpdated
     265             :     {
     266             :         constexpr static const char* name = "ConversationPreferencesUpdated";
     267             :         using cb_type = void(const std::string& /*accountId*/,
     268             :                              const std::string& /*conversationId*/,
     269             :                              std::map<std::string, std::string> /*preferences*/);
     270             :     };
     271             : };
     272             : 
     273             : } // namespace libjami
     274             : 
     275             : #endif // LIBJAMI_CONVERSATIONI_H

Generated by: LCOV version 1.14