Callback system

From RetroShare
Jump to: navigation, search

The callback system is performed using the Notify class. Two classes, NotifyTXT and NotifyQt derive from the same NotifyBase pure virtual class.

The NotifyQt is responsible for sending messages to the interface and various windows open. This can be done in several ways, provided that the interface is correctly locked to avoid concurrent write access from different threads.

csoler: Up to me the best way to do this is to use the signal system of Qt: For each functionality NotifyQt has a signal that is connected to a slot of the target window.

Indeed, Qt already has a queue system to handle events from threads, so all actions requested by a signal are handled properly even if they come from threads. That's what I've done for displayig hashing info: Thread 1:

  • fimonitor calls NotifyBase::hashingInfo(std::string)
  • NotifyBase::hashingInfo(std::string) is derived into NotifyQt::hashingInfo(std::string)
  • NotifyQt::hashingInfo(std::string) emits the signal hashingInfo(QString)

Thread 2:

  • MainWindow receives this signal on its slot displayHasingInfo(QString) and performs the display.

Proposed tasks:

  • suppress the interface lock that is called sometimes in NotifyQt and use Qt signals instead
  • merge p3notify and NotifyBase classes.
Personal tools

External websites