2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef TERMINAL_ROSTER_H
6 #define TERMINAL_ROSTER_H
13 #include <ObjectList.h>
16 /*! Provides access to the (virtual) global terminal roster.
18 Register() registers our terminal with the roster and establishes the link
19 to the roster. From then on CountTerminals() and TerminalAt() provide
20 access to the terminal list and allows to post our window status via
21 SetWindowInfo(). The list is automatically kept up to date. Unregister()
22 will remove our terminal from the roster and terminate the connection.
24 A single Listener can be set. It is notified whenever the terminal list
27 class TerminalRoster
: private BHandler
{
39 Info(int32 id
, team_id team
);
40 Info(const BMessage
& archive
);
42 status_t
Archive(BMessage
& archive
) const;
44 bool operator==(const Info
& other
) const;
45 bool operator!=(const Info
& other
) const
46 { return !(*this == other
); }
55 status_t
Register(team_id teamID
, BLooper
* looper
);
57 bool IsRegistered() const
58 { return fOurInfo
!= NULL
; }
62 void SetWindowInfo(bool minimized
,
65 // roster must be locked
66 int32
CountTerminals() const
67 { return fInfos
.CountItems(); }
68 const Info
* TerminalAt(int32 index
) const
69 { return fInfos
.ItemAt(index
); }
71 void SetListener(Listener
* listener
)
72 { fListener
= listener
; }
76 virtual void MessageReceived(BMessage
* message
);
79 typedef BObjectList
<Info
> InfoList
;
82 status_t
_UpdateInfos(bool checkApps
);
83 status_t
_UpdateClipboard();
85 void _NotifyListener();
87 static int _CompareInfos(const Info
* a
, const Info
* b
);
88 static int _CompareIDInfo(const int32
* id
,
91 bool _TeamIsRunning(team_id teamID
);
95 BClipboard fClipboard
;
98 bigtime_t fLastCheckedTime
;
104 class TerminalRoster::Listener
{
108 virtual void TerminalInfosUpdated(TerminalRoster
* roster
)
113 #endif // TERMINAL_ROSTER_H