2016-09-05 19:06:26 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2016 Mnemosyne LLC
|
|
|
|
*
|
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
#include "tr-macros.h"
|
|
|
|
|
|
|
|
TR_BEGIN_DECLS
|
2016-09-05 19:06:26 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
typedef struct tr_session_id* tr_session_id_t;
|
2016-09-05 19:06:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create new session identifier object.
|
|
|
|
*
|
|
|
|
* @return New session identifier object.
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_session_id_t tr_session_id_new(void);
|
2016-09-05 19:06:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free session identifier object.
|
|
|
|
*
|
|
|
|
* @param[in] session_id Session identifier object.
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_session_id_free(tr_session_id_t session_id);
|
2016-09-05 19:06:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get current session identifier as string.
|
|
|
|
*
|
|
|
|
* @param[in] session_id Session identifier object.
|
|
|
|
*
|
|
|
|
* @return String representation of current session identifier.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
char const* tr_session_id_get_current(tr_session_id_t session_id);
|
2016-09-05 19:06:26 +00:00
|
|
|
|
2016-09-21 20:56:03 +00:00
|
|
|
/**
|
|
|
|
* Check if session ID corresponds to session running on the same machine as
|
|
|
|
* the caller.
|
|
|
|
*
|
|
|
|
* This is useful for various behavior alterations, such as transforming
|
|
|
|
* relative paths to absolute before passing through RPC, or presenting
|
|
|
|
* different UI for local and remote sessions.
|
|
|
|
*
|
|
|
|
* @param[in] session_id String representation of session identifier object.
|
|
|
|
*
|
|
|
|
* @return `True` if session is valid and local, `false` otherwise.
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
bool tr_session_id_is_local(char const* session_id);
|
2016-09-21 20:56:03 +00:00
|
|
|
|
2020-08-11 18:11:55 +00:00
|
|
|
TR_END_DECLS
|