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

Generated by: LCOV version 2.0-1