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-04-24 08:04:06 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  Copyright (C) 2004-2024 Savoir-faire Linux Inc.
       3             :  *
       4             :  *  Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
       5             :  *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
       6             :  *  Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com>
       7             :  *
       8             :  *  This program is free software; you can redistribute it and/or modify
       9             :  *  it under the terms of the GNU General Public License as published by
      10             :  *  the Free Software Foundation; either version 3 of the License, or
      11             :  *  (at your option) any later version.
      12             :  *
      13             :  *  This program is distributed in the hope that it will be useful,
      14             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  *  GNU General Public License for more details.
      17             :  *
      18             :  *  You should have received a copy of the GNU General Public License
      19             :  *  along with this program; if not, write to the Free Software
      20             :  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
      21             :  */
      22             : 
      23             : #pragma once
      24             : 
      25             : #include <string>
      26             : #include <vector>
      27             : #include <map>
      28             : #include <list>
      29             : #include <stdexcept>
      30             : 
      31             : #ifdef HAVE_CONFIG_H
      32             : #include "config.h"
      33             : #endif
      34             : 
      35             : extern "C" {
      36             : struct pjsip_inv_session;
      37             : struct pjsip_rx_data;
      38             : struct pjsip_msg;
      39             : struct pjsip_tx_data;
      40             : }
      41             : 
      42             : namespace jami {
      43             : namespace im {
      44             : 
      45             : struct InstantMessageException : std::runtime_error
      46             : {
      47           1 :     InstantMessageException(const std::string& str = "")
      48           1 :         : std::runtime_error("InstantMessageException occurred: " + str)
      49           1 :     {}
      50             : };
      51             : 
      52             : /**
      53             :  * Constructs and sends a SIP message.
      54             :  *
      55             :  * The expected format of the map key is:
      56             :  *     type/subtype[; *[; arg=value]]
      57             :  *     eg: "text/plain; id=1234;part=2;of=1001"
      58             :  *     note: all whitespace is optional
      59             :  *
      60             :  * If the map contains more than one pair, then a multipart/mixed message type will be created
      61             :  * containing multiple message parts. Note that all of the message parts must be able to fit into
      62             :  * one message... they will not be split into multiple messages.
      63             :  *
      64             :  * @param session SIP session
      65             :  * @param payloads a map where the mime type and optional parameters are the key
      66             :  *                 and the message payload is the value
      67             :  *
      68             :  * Exception: throw InstantMessageException if no message sent
      69             :  */
      70             : void sendSipMessage(pjsip_inv_session* session, const std::map<std::string, std::string>& payloads);
      71             : 
      72             : /**
      73             :  * Parses given SIP message into a map where the key is the contents of the Content-Type header
      74             :  * (along with any parameters) and the value is the message payload.
      75             :  *
      76             :  * @param msg received SIP message
      77             :  *
      78             :  * @return map of content types and message payloads
      79             :  */
      80             : std::map<std::string, std::string> parseSipMessage(const pjsip_msg* msg);
      81             : 
      82             : void fillPJSIPMessageBody(pjsip_tx_data& tdata, const std::map<std::string, std::string>& payloads);
      83             : 
      84             : } // namespace im
      85             : } // namespace jami

Generated by: LCOV version 1.14