LCOV - code coverage report
Current view: top level - src/im - instant_messaging.h (source / functions) Hit Total Coverage
Test: jami-coverage-filtered.info Lines: 3 3 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             : #pragma once
      18             : 
      19             : #include <string>
      20             : #include <vector>
      21             : #include <map>
      22             : #include <list>
      23             : #include <stdexcept>
      24             : 
      25             : #ifdef HAVE_CONFIG_H
      26             : #include "config.h"
      27             : #endif
      28             : 
      29             : extern "C" {
      30             : struct pjsip_inv_session;
      31             : struct pjsip_rx_data;
      32             : struct pjsip_msg;
      33             : struct pjsip_tx_data;
      34             : }
      35             : 
      36             : namespace jami {
      37             : namespace im {
      38             : 
      39             : struct InstantMessageException : std::runtime_error
      40             : {
      41           1 :     InstantMessageException(const std::string& str = "")
      42           1 :         : std::runtime_error("InstantMessageException occurred: " + str)
      43           1 :     {}
      44             : };
      45             : 
      46             : /**
      47             :  * Constructs and sends a SIP message.
      48             :  *
      49             :  * The expected format of the map key is:
      50             :  *     type/subtype[; *[; arg=value]]
      51             :  *     eg: "text/plain; id=1234;part=2;of=1001"
      52             :  *     note: all whitespace is optional
      53             :  *
      54             :  * If the map contains more than one pair, then a multipart/mixed message type will be created
      55             :  * containing multiple message parts. Note that all of the message parts must be able to fit into
      56             :  * one message... they will not be split into multiple messages.
      57             :  *
      58             :  * @param session SIP session
      59             :  * @param payloads a map where the mime type and optional parameters are the key
      60             :  *                 and the message payload is the value
      61             :  *
      62             :  * Exception: throw InstantMessageException if no message sent
      63             :  */
      64             : void sendSipMessage(pjsip_inv_session* session, const std::map<std::string, std::string>& payloads);
      65             : 
      66             : /**
      67             :  * Parses given SIP message into a map where the key is the contents of the Content-Type header
      68             :  * (along with any parameters) and the value is the message payload.
      69             :  *
      70             :  * @param msg received SIP message
      71             :  *
      72             :  * @return map of content types and message payloads
      73             :  */
      74             : std::map<std::string, std::string> parseSipMessage(const pjsip_msg* msg);
      75             : 
      76             : void fillPJSIPMessageBody(pjsip_tx_data& tdata, const std::map<std::string, std::string>& payloads);
      77             : 
      78             : } // namespace im
      79             : } // namespace jami

Generated by: LCOV version 1.14