qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
Classes | Public Slots | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SessionChatLog Class Reference

#include <sessionchatlog.h>

Inheritance diagram for SessionChatLog:
Inheritance graph
Collaboration diagram for SessionChatLog:
Collaboration graph

Classes

struct  CurrentFileTransfer
 

Public Slots

void onMessageReceived (const ToxPk &sender, const Message &message)
 Inserts message data into the chatlog buffer. More...
 
void onMessageSent (DispatchedMessageId id, const Message &message)
 Inserts message data into the chatlog buffer. More...
 
void onMessageComplete (DispatchedMessageId id)
 Marks the associated message as complete and notifies any listeners. More...
 
void onMessageBroken (DispatchedMessageId id, BrokenMessageReason reason)
 
void onFileUpdated (const ToxPk &sender, const ToxFile &file)
 Updates file state in the chatlog. More...
 
void onFileTransferRemotePausedUnpaused (const ToxPk &sender, const ToxFile &file, bool paused)
 
void onFileTransferBrokenUnbroken (const ToxPk &sender, const ToxFile &file, bool broken)
 

Public Member Functions

 SessionChatLog (const ICoreIdHandler &coreIdHandler)
 
 SessionChatLog (ChatLogIdx initialIdx, const ICoreIdHandler &coreIdHandler)
 Alternate constructor that allows for an initial index to be set. More...
 
 ~SessionChatLog ()
 
const ChatLogItemat (ChatLogIdx idx) const override
 Returns reference to item at idx. More...
 
SearchResult searchForward (SearchPos startIdx, const QString &phrase, const ParameterSearch &parameter) const override
 searches forwards through the chat log until phrase is found according to parameter More...
 
SearchResult searchBackward (SearchPos startIdx, const QString &phrase, const ParameterSearch &parameter) const override
 searches backwards through the chat log until phrase is found according to parameter More...
 
ChatLogIdx getFirstIdx () const override
 The underlying chat log instance may not want to start at 0. More...
 
ChatLogIdx getNextIdx () const override
 
std::vector< DateChatLogIdxPairgetDateIdxs (const QDate &startDate, size_t maxDates) const override
 Gets indexes for each new date starting at startDate. More...
 
void addSystemMessage (const SystemMessage &message) override
 Inserts a system message at the end of the chat. More...
 
void insertCompleteMessageAtIdx (ChatLogIdx idx, const ToxPk &sender, QString senderName, const ChatLogMessage &message)
 
void insertIncompleteMessageAtIdx (ChatLogIdx idx, const ToxPk &sender, QString senderName, const ChatLogMessage &message, DispatchedMessageId dispatchId)
 
void insertBrokenMessageAtIdx (ChatLogIdx idx, const ToxPk &sender, QString senderName, const ChatLogMessage &message)
 
void insertFileAtIdx (ChatLogIdx idx, const ToxPk &sender, QString senderName, const ChatLogFile &file)
 
void insertSystemMessageAtIdx (ChatLogIdx idx, SystemMessage message)
 
- Public Member Functions inherited from IChatLog
virtual ~IChatLog ()=default
 

Private Member Functions

QString resolveSenderNameFromSender (const ToxPk &sender)
 

Private Attributes

const ICoreIdHandlercoreIdHandler
 
ChatLogIdx nextIdx = ChatLogIdx(0)
 
std::map< ChatLogIdx, ChatLogItemitems
 
std::vector< CurrentFileTransfercurrentFileTransfers
 
QMap< DispatchedMessageId, ChatLogIdxoutgoingMessages
 

Additional Inherited Members

- Signals inherited from IChatLog
void itemUpdated (ChatLogIdx idx)
 

Detailed Description

Definition at line 31 of file sessionchatlog.h.

Constructor & Destructor Documentation

◆ SessionChatLog() [1/2]

SessionChatLog::SessionChatLog ( const ICoreIdHandler coreIdHandler)

Definition at line 128 of file sessionchatlog.cpp.

◆ SessionChatLog() [2/2]

SessionChatLog::SessionChatLog ( ChatLogIdx  initialIdx,
const ICoreIdHandler coreIdHandler 
)

Alternate constructor that allows for an initial index to be set.

Definition at line 135 of file sessionchatlog.cpp.

◆ ~SessionChatLog()

SessionChatLog::~SessionChatLog ( )
default

Member Function Documentation

◆ addSystemMessage()

void SessionChatLog::addSystemMessage ( const SystemMessage message)
overridevirtual

Inserts a system message at the end of the chat.

Parameters
[in]messagesystemMessage to insert

Implements IChatLog.

Definition at line 322 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ at()

const ChatLogItem & SessionChatLog::at ( ChatLogIdx  idx) const
overridevirtual

Returns reference to item at idx.

Parameters
[in]idx
Returns
Variant type referencing either a ToxFile or Message
Precondition
idx must be between currentFirstIdx() and currentLastIdx()

Implements IChatLog.

Definition at line 150 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ getDateIdxs()

std::vector< IChatLog::DateChatLogIdxPair > SessionChatLog::getDateIdxs ( const QDate &  startDate,
size_t  maxDates 
) const
overridevirtual

Gets indexes for each new date starting at startDate.

Parameters
[in]startDatedate to start searching from
[in]maxDatesmaximum number of dates to be returned

Implements IChatLog.

Definition at line 294 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ getFirstIdx()

ChatLogIdx SessionChatLog::getFirstIdx ( ) const
overridevirtual

The underlying chat log instance may not want to start at 0.

Returns
Current first valid index to call at() with

Implements IChatLog.

Definition at line 280 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ getNextIdx()

ChatLogIdx SessionChatLog::getNextIdx ( ) const
overridevirtual
Returns
current last valid index to call at() with

Implements IChatLog.

Definition at line 289 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ insertBrokenMessageAtIdx()

void SessionChatLog::insertBrokenMessageAtIdx ( ChatLogIdx  idx,
const ToxPk sender,
QString  senderName,
const ChatLogMessage message 
)

Definition at line 353 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ insertCompleteMessageAtIdx()

void SessionChatLog::insertCompleteMessageAtIdx ( ChatLogIdx  idx,
const ToxPk sender,
QString  senderName,
const ChatLogMessage message 
)

Definition at line 331 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ insertFileAtIdx()

void SessionChatLog::insertFileAtIdx ( ChatLogIdx  idx,
const ToxPk sender,
QString  senderName,
const ChatLogFile file 
)

Definition at line 363 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ insertIncompleteMessageAtIdx()

void SessionChatLog::insertIncompleteMessageAtIdx ( ChatLogIdx  idx,
const ToxPk sender,
QString  senderName,
const ChatLogMessage message,
DispatchedMessageId  dispatchId 
)

Definition at line 341 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ insertSystemMessageAtIdx()

void SessionChatLog::insertSystemMessageAtIdx ( ChatLogIdx  idx,
SystemMessage  message 
)

Definition at line 370 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ onFileTransferBrokenUnbroken

void SessionChatLog::onFileTransferBrokenUnbroken ( const ToxPk sender,
const ToxFile file,
bool  broken 
)
slot

Definition at line 507 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onFileTransferRemotePausedUnpaused

void SessionChatLog::onFileTransferRemotePausedUnpaused ( const ToxPk sender,
const ToxFile file,
bool  paused 
)
slot

Definition at line 501 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onFileUpdated

void SessionChatLog::onFileUpdated ( const ToxPk sender,
const ToxFile file 
)
slot

Updates file state in the chatlog.

Note
The files need to be pre-filtered for the current chat since we do no validation
This should be attached to any CoreFile signal that fits the signature

Definition at line 467 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMessageBroken

void SessionChatLog::onMessageBroken ( DispatchedMessageId  id,
BrokenMessageReason  reason 
)
slot

Definition at line 439 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ onMessageComplete

void SessionChatLog::onMessageComplete ( DispatchedMessageId  id)
slot

Marks the associated message as complete and notifies any listeners.

Note
Owner of SessionChatLog is in charge of attaching this to the appropriate IMessageDispatcher

Definition at line 417 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ onMessageReceived

void SessionChatLog::onMessageReceived ( const ToxPk sender,
const Message message 
)
slot

Inserts message data into the chatlog buffer.

Note
Owner of SessionChatLog is in charge of attaching this to the appropriate IMessageDispatcher

Definition at line 381 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onMessageSent

void SessionChatLog::onMessageSent ( DispatchedMessageId  id,
const Message message 
)
slot

Inserts message data into the chatlog buffer.

Note
Owner of SessionChatLog is in charge of attaching this to the appropriate IMessageDispatcher

Definition at line 397 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolveSenderNameFromSender()

QString SessionChatLog::resolveSenderNameFromSender ( const ToxPk sender)
private

Definition at line 142 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ searchBackward()

SearchResult SessionChatLog::searchBackward ( SearchPos  startIdx,
const QString &  phrase,
const ParameterSearch parameter 
) const
overridevirtual

searches backwards through the chat log until phrase is found according to parameter

Parameters
[in]startIdxinclusive start idx
[in]phrasephrase to find (may be modified by parameter)
[in]parametersearch parameters

Implements IChatLog.

Definition at line 213 of file sessionchatlog.cpp.

Here is the caller graph for this function:

◆ searchForward()

SearchResult SessionChatLog::searchForward ( SearchPos  startIdx,
const QString &  phrase,
const ParameterSearch parameter 
) const
overridevirtual

searches forwards through the chat log until phrase is found according to parameter

Parameters
[in]startIdxinclusive start idx
[in]phrasephrase to find (may be modified by parameter)
[in]parametersearch parameters

Implements IChatLog.

Definition at line 160 of file sessionchatlog.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ coreIdHandler

const ICoreIdHandler& SessionChatLog::coreIdHandler
private

Definition at line 74 of file sessionchatlog.h.

◆ currentFileTransfers

std::vector<CurrentFileTransfer> SessionChatLog::currentFileTransfers
private

Short list of active file transfers in given log. This is to make it so we don't have to search through all files that have ever been transferred in order to find our existing transfers

Definition at line 91 of file sessionchatlog.h.

◆ items

std::map<ChatLogIdx, ChatLogItem> SessionChatLog::items
private

Definition at line 78 of file sessionchatlog.h.

◆ nextIdx

ChatLogIdx SessionChatLog::nextIdx = ChatLogIdx(0)
private

Definition at line 76 of file sessionchatlog.h.

◆ outgoingMessages

QMap<DispatchedMessageId, ChatLogIdx> SessionChatLog::outgoingMessages
private

Maps DispatchedMessageIds back to ChatLogIdxs. Messages are removed when the message is marked as completed

Definition at line 97 of file sessionchatlog.h.


The documentation for this class was generated from the following files: