Overall Structure of the TerraIM Source
All the TerraIM source code is organized in two main
cathegories: the graphical user interface (GUI) and
the protocol implementation. The GUI consists of all
elements that directly interact with the user, such as
the windows, dialogs, sounds, mouse and keyboard
input, and the system tray.
To enable the GUI to work with different underlying
protocols (such as TOC and OSCAR), the GUI interacts
with the protocol impementation through a generic
protocol interface found in Protocol.h. Every
element of the GUI keeps a pointer to an instance of
this interface. On the
other hand, the protocol implementation communicates
with the GUI by sending events, which are defined in
MessagingProtocolEvent.h. The above abstract mode
of communication allows the protocol implementation
and GUI to be implemented without depending on each
other.
GUI Components
The events & windows
Each window has a corresponding class, derived either
from wxFrame or wxDialog, which is instantiated to
create the window. The following files each contain
the definition for one window:
AwayMessagesWindow.h, ChatWindow.h, Driver.h (which
contains the buddy list window),
FTProgressWindow.h, IMPanel.h, InfoWindow.h,
LoginPreferencesWindow.h, LoginWindow.h, OIMwindow.h,
PreferencesWindow.h, ShowAwayMsgWidnow.h,
SingeIMFrame.h, TabbedIMFrame.h
Events are propagated as follows: the buddy list
window receives all protocol events and then re-posts
them to all currently open windows. Each particular
window captures the events with the
EVT_MESSAGING_PROTOCOL(handler_function) macro. All
the possible events that could be issued are defined
in MessagingProtocolEvent.h.
Saving and Retrieving Preferences
In many places around the code it is necessary to read
the user's saved preferences, for example to check
whether sounds should play or not. All the functions
for reading and storing preferences are found in
GlobalConfig.h. For each setting there is a
Get____ function to read the setting and a
corresponding Set_____ function to save a new value.
Many getter functions require a default value which
will be returned in case there was no previously saved
preference. Also, it is not necessary to worry wether
a setting is being saved to a file or to the registry,
since the GlobalConfig class takes care of these
details.
Topics to be written: the Protocol interface
and implementation, sound playing system, logging implementation, future plans.
|