LCOV - code coverage report
Current view: top level - src/jami - conversation_interface.h (source / functions) Coverage Total Hit
Test: jami-coverage-filtered.info Lines: 100.0 % 5 5
Test Date: 2026-06-13 09:18:46 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :  *  Copyright (C) 2004-2026 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 <cstdint>
      27              : 
      28              : namespace libjami {
      29              : 
      30              : struct SwarmMessage
      31              : {
      32              :     std::string id;
      33              :     std::string type;
      34              :     std::string linearizedParent;
      35              :     std::map<std::string, std::string> body;
      36              :     std::vector<std::map<std::string, std::string>> reactions;
      37              :     std::vector<std::map<std::string, std::string>> editions;
      38              :     std::map<std::string, int32_t> status;
      39              : 
      40         9490 :     void fromMapStringString(const std::map<std::string, std::string>& commit)
      41              :     {
      42        18963 :         id = commit.at("id");
      43         9473 :         type = commit.at("type");
      44         9480 :         body = commit; // TODO erase type/id?
      45         9493 :     }
      46              : };
      47              : 
      48              : // Conversation management
      49              : LIBJAMI_PUBLIC std::string startConversation(const std::string& accountId);
      50              : LIBJAMI_PUBLIC void acceptConversationRequest(const std::string& accountId, const std::string& conversationId);
      51              : LIBJAMI_PUBLIC void declineConversationRequest(const std::string& accountId, const std::string& conversationId);
      52              : LIBJAMI_PUBLIC bool removeConversation(const std::string& accountId, const std::string& conversationId);
      53              : LIBJAMI_PUBLIC std::vector<std::string> getConversations(const std::string& accountId);
      54              : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConversationRequests(const std::string& accountId);
      55              : 
      56              : // Calls
      57              : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getActiveCalls(const std::string& accountId,
      58              :                                                                               const std::string& conversationId);
      59              : 
      60              : // Conversation's infos management
      61              : LIBJAMI_PUBLIC void updateConversationInfos(const std::string& accountId,
      62              :                                             const std::string& conversationId,
      63              :                                             const std::map<std::string, std::string>& infos);
      64              : LIBJAMI_PUBLIC std::map<std::string, std::string> conversationInfos(const std::string& accountId,
      65              :                                                                     const std::string& conversationId);
      66              : LIBJAMI_PUBLIC void setConversationPreferences(const std::string& accountId,
      67              :                                                const std::string& conversationId,
      68              :                                                const std::map<std::string, std::string>& prefs);
      69              : LIBJAMI_PUBLIC std::map<std::string, std::string> getConversationPreferences(const std::string& accountId,
      70              :                                                                              const std::string& conversationId);
      71              : 
      72              : // Member management
      73              : LIBJAMI_PUBLIC void addConversationMember(const std::string& accountId,
      74              :                                           const std::string& conversationId,
      75              :                                           const std::string& contactUri);
      76              : LIBJAMI_PUBLIC void removeConversationMember(const std::string& accountId,
      77              :                                              const std::string& conversationId,
      78              :                                              const std::string& contactUri);
      79              : LIBJAMI_PUBLIC std::vector<std::map<std::string, std::string>> getConversationMembers(const std::string& accountId,
      80              :                                                                                       const std::string& conversationId);
      81              : 
      82              : // Message send/load
      83              : LIBJAMI_PUBLIC void sendMessage(const std::string& accountId,
      84              :                                 const std::string& conversationId,
      85              :                                 const std::string& message,
      86              :                                 const std::string& replyTo,
      87              :                                 const int32_t& flag = 0);
      88              : LIBJAMI_PUBLIC uint32_t loadConversation(const std::string& accountId,
      89              :                                          const std::string& conversationId,
      90              :                                          const std::string& fromMessage,
      91              :                                          size_t n);
      92              : LIBJAMI_PUBLIC uint32_t loadSwarmUntil(const std::string& accountId,
      93              :                                        const std::string& conversationId,
      94              :                                        const std::string& fromMessage,
      95              :                                        const std::string& toMessage);
      96              : LIBJAMI_PUBLIC uint32_t countInteractions(const std::string& accountId,
      97              :                                           const std::string& conversationId,
      98              :                                           const std::string& toId,
      99              :                                           const std::string& fromId,
     100              :                                           const std::string& authorUri);
     101              : LIBJAMI_PUBLIC void clearCache(const std::string& accountId, const std::string& conversationId);
     102              : LIBJAMI_PUBLIC uint32_t searchConversation(const std::string& accountId,
     103              :                                            const std::string& conversationId,
     104              :                                            const std::string& author,
     105              :                                            const std::string& lastId,
     106              :                                            const std::string& regexSearch,
     107              :                                            const std::string& type,
     108              :                                            const int64_t& after,
     109              :                                            const int64_t& before,
     110              :                                            const uint32_t& maxResult,
     111              :                                            const int32_t& flag);
     112              : LIBJAMI_PUBLIC void reloadConversationsAndRequests(const std::string& accountId);
     113              : 
     114              : struct LIBJAMI_PUBLIC ConversationSignal
     115              : {
     116              :     struct LIBJAMI_PUBLIC SwarmLoaded
     117              :     {
     118              :         constexpr static const char* name = "SwarmLoaded";
     119              :         using cb_type = void(uint32_t /* id */,
     120              :                              const std::string& /*accountId*/,
     121              :                              const std::string& /* conversationId */,
     122              :                              std::vector<SwarmMessage> /*messages*/);
     123              :     };
     124              :     struct LIBJAMI_PUBLIC MessagesFound
     125              :     {
     126              :         constexpr static const char* name = "MessagesFound";
     127              :         using cb_type = void(uint32_t /* id */,
     128              :                              const std::string& /*accountId*/,
     129              :                              const std::string& /* conversationId */,
     130              :                              std::vector<std::map<std::string, std::string>> /*messages*/);
     131              :     };
     132              :     struct LIBJAMI_PUBLIC SwarmMessageReceived
     133              :     {
     134              :         constexpr static const char* name = "SwarmMessageReceived";
     135              :         using cb_type = void(const std::string& /*accountId*/,
     136              :                              const std::string& /* conversationId */,
     137              :                              const SwarmMessage& /*message*/);
     138              :     };
     139              :     struct LIBJAMI_PUBLIC SwarmMessageUpdated
     140              :     {
     141              :         constexpr static const char* name = "SwarmMessageUpdated";
     142              :         using cb_type = void(const std::string& /*accountId*/,
     143              :                              const std::string& /* conversationId */,
     144              :                              const SwarmMessage& /*message*/);
     145              :     };
     146              :     struct LIBJAMI_PUBLIC ReactionAdded
     147              :     {
     148              :         constexpr static const char* name = "ReactionAdded";
     149              :         using cb_type = void(const std::string& /*accountId*/,
     150              :                              const std::string& /* conversationId */,
     151              :                              const std::string& /* messageId */,
     152              :                              std::map<std::string, std::string> /*reaction*/);
     153              :     };
     154              :     struct LIBJAMI_PUBLIC ReactionRemoved
     155              :     {
     156              :         constexpr static const char* name = "ReactionRemoved";
     157              :         using cb_type = void(const std::string& /*accountId*/,
     158              :                              const std::string& /* conversationId */,
     159              :                              const std::string& /* messageId */,
     160              :                              const std::string& /* reactionId */);
     161              :     };
     162              :     struct LIBJAMI_PUBLIC ConversationProfileUpdated
     163              :     {
     164              :         constexpr static const char* name = "ConversationProfileUpdated";
     165              :         using cb_type = void(const std::string& /*accountId*/,
     166              :                              const std::string& /* conversationId */,
     167              :                              std::map<std::string, std::string> /*profile*/);
     168              :     };
     169              :     struct LIBJAMI_PUBLIC ConversationRequestReceived
     170              :     {
     171              :         constexpr static const char* name = "ConversationRequestReceived";
     172              :         using cb_type = void(const std::string& /*accountId*/,
     173              :                              const std::string& /* conversationId */,
     174              :                              std::map<std::string, std::string> /*metadatas*/);
     175              :     };
     176              :     struct LIBJAMI_PUBLIC ConversationRequestDeclined
     177              :     {
     178              :         constexpr static const char* name = "ConversationRequestDeclined";
     179              :         using cb_type = void(const std::string& /*accountId*/, const std::string& /* conversationId */);
     180              :     };
     181              :     struct LIBJAMI_PUBLIC ConversationReady
     182              :     {
     183              :         constexpr static const char* name = "ConversationReady";
     184              :         using cb_type = void(const std::string& /*accountId*/, const std::string& /* conversationId */);
     185              :     };
     186              :     struct LIBJAMI_PUBLIC ConversationRemoved
     187              :     {
     188              :         constexpr static const char* name = "ConversationRemoved";
     189              :         using cb_type = void(const std::string& /*accountId*/, const std::string& /* conversationId */);
     190              :     };
     191              :     struct LIBJAMI_PUBLIC ConversationMemberEvent
     192              :     {
     193              :         constexpr static const char* name = "ConversationMemberEvent";
     194              :         using cb_type = void(const std::string& /*accountId*/,
     195              :                              const std::string& /* conversationId */,
     196              :                              const std::string& /* memberUri */,
     197              :                              int /* event 0 = add, 1 = joins, 2 = leave, 3 = banned */);
     198              :     };
     199              : 
     200              :     struct LIBJAMI_PUBLIC ConversationSyncFinished
     201              :     {
     202              :         constexpr static const char* name = "ConversationSyncFinished";
     203              :         using cb_type = void(const std::string& /*accountId*/);
     204              :     };
     205              : 
     206              :     struct LIBJAMI_PUBLIC ConversationCloned
     207              :     {
     208              :         constexpr static const char* name = "ConversationCloned";
     209              :         using cb_type = void(const std::string& /*accountId*/);
     210              :     };
     211              : 
     212              :     struct LIBJAMI_PUBLIC CallConnectionRequest
     213              :     {
     214              :         constexpr static const char* name = "CallConnectionRequest";
     215              :         using cb_type = void(const std::string& /*accountId*/, const std::string& /*peerId*/, bool hasVideo);
     216              :     };
     217              : 
     218              :     struct LIBJAMI_PUBLIC OnConversationError
     219              :     {
     220              :         constexpr static const char* name = "OnConversationError";
     221              :         using cb_type = void(const std::string& /*accountId*/,
     222              :                              const std::string& /* conversationId */,
     223              :                              int code,
     224              :                              const std::string& what);
     225              :     };
     226              : 
     227              :     // Preferences
     228              :     struct LIBJAMI_PUBLIC ConversationPreferencesUpdated
     229              :     {
     230              :         constexpr static const char* name = "ConversationPreferencesUpdated";
     231              :         using cb_type = void(const std::string& /*accountId*/,
     232              :                              const std::string& /*conversationId*/,
     233              :                              std::map<std::string, std::string> /*preferences*/);
     234              :     };
     235              : };
     236              : 
     237              : } // namespace libjami
     238              : 
     239              : #endif // LIBJAMI_CONVERSATIONI_H
        

Generated by: LCOV version 2.0-1