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-12-21 08:56:24 Functions: 1 1 100.0 %

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

Generated by: LCOV version 1.14