diff --git a/src/servers/registrar/AppInfoList.cpp b/src/servers/registrar/AppInfoList.cpp new file mode 100644 index 0000000000..c3689bd15e --- /dev/null +++ b/src/servers/registrar/AppInfoList.cpp @@ -0,0 +1,128 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: AppInfoList.cpp +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: A helper class for TRoster. A list of RosterAppInfos. +//------------------------------------------------------------------------------ + +#include "AppInfoList.h" +#include "RosterAppInfo.h" + +// constructor +AppInfoList::AppInfoList() + : fInfos() +{ +} + +// constructor +AppInfoList::~AppInfoList() +{ + // delete all infos + for (int32 i = 0; RosterAppInfo *info = InfoAt(i); i++) + delete info; +} + +// AddInfo +bool +AppInfoList::AddInfo(RosterAppInfo *info, int32 index) +{ + bool result = false; + if (info) { + if (index < 0) + result = fInfos.AddItem(info); + else + result = fInfos.AddItem(info, index); + } + return result; +} + +// RemoveInfo +RosterAppInfo * +AppInfoList::RemoveInfo(int32 index) +{ + return (RosterAppInfo*)fInfos.RemoveItem(index); +} + +// RemoveInfo +bool +AppInfoList::RemoveInfo(RosterAppInfo *info) +{ + return fInfos.RemoveItem(info); +} + +// IndexOf +int32 +AppInfoList::IndexOf(RosterAppInfo *info) const +{ + return fInfos.IndexOf(info); +} + +// IndexOf +int32 +AppInfoList::IndexOf(const char *signature) const +{ + for (int32 i = 0; RosterAppInfo *info = InfoAt(i); i++) { + if (!strcmp(info->signature, signature)) + return i; + } + return -1; +} + +// IndexOf +int32 +AppInfoList::IndexOf(team_id team) const +{ + for (int32 i = 0; RosterAppInfo *info = InfoAt(i); i++) { + if (info->team == team) + return i; + } + return -1; +} + +// InfoAt +RosterAppInfo * +AppInfoList::InfoAt(int32 index) const +{ + return (RosterAppInfo*)fInfos.ItemAt(index); +} + +// InfoFor +RosterAppInfo * +AppInfoList::InfoFor(const char *signature) const +{ + return InfoAt(IndexOf(signature)); +} + +// InfoFor +RosterAppInfo * +AppInfoList::InfoFor(team_id team) const +{ + return InfoAt(IndexOf(team)); +} + +// CountInfos +int32 +AppInfoList::CountInfos() const +{ + return fInfos.CountItems(); +} + diff --git a/src/servers/registrar/AppInfoList.h b/src/servers/registrar/AppInfoList.h new file mode 100644 index 0000000000..90d53577f9 --- /dev/null +++ b/src/servers/registrar/AppInfoList.h @@ -0,0 +1,59 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: AppInfoList.h +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: A helper class for TRoster. A list of RosterAppInfos. +//------------------------------------------------------------------------------ + +#ifndef APP_INFO_LIST_H +#define APP_INFO_LIST_H + +#include +#include + +class RosterAppInfo; + +class AppInfoList { +public: + AppInfoList(); + virtual ~AppInfoList(); + + bool AddInfo(RosterAppInfo *info, int32 index = -1); + + RosterAppInfo *RemoveInfo(int32 index); + bool RemoveInfo(RosterAppInfo *info); + + int32 IndexOf(RosterAppInfo *info) const; + int32 IndexOf(const char *signature) const; + int32 IndexOf(team_id team) const; + + RosterAppInfo *InfoAt(int32 index) const; + RosterAppInfo *InfoFor(const char *signature) const; + RosterAppInfo *InfoFor(team_id team) const; + + int32 CountInfos() const; + +private: + BList fInfos; +}; + +#endif // APP_INFO_LIST_H diff --git a/src/servers/registrar/Jamfile b/src/servers/registrar/Jamfile index 333309ae48..8d4e8b4e25 100644 --- a/src/servers/registrar/Jamfile +++ b/src/servers/registrar/Jamfile @@ -4,9 +4,12 @@ UsePublicHeaders app ; UsePrivateHeaders app ; Server obos_registrar : + AppInfoList.cpp ClipboardHandler.cpp MIMEManager.cpp Registrar.cpp + RosterAppInfo.cpp + TRoster.cpp ; LinkSharedOSLibs obos_registrar : libopenbeos.so diff --git a/src/servers/registrar/RosterAppInfo.cpp b/src/servers/registrar/RosterAppInfo.cpp new file mode 100644 index 0000000000..69c8f3aa53 --- /dev/null +++ b/src/servers/registrar/RosterAppInfo.cpp @@ -0,0 +1,35 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: RosterAppInfo.cpp +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: An extended app_info. +//------------------------------------------------------------------------------ + +#include "RosterAppInfo.h" + +// constructor +RosterAppInfo::RosterAppInfo() + : app_info(), + state(APP_STATE_INVALID) +{ +} + diff --git a/src/servers/registrar/RosterAppInfo.h b/src/servers/registrar/RosterAppInfo.h new file mode 100644 index 0000000000..8f81e31af2 --- /dev/null +++ b/src/servers/registrar/RosterAppInfo.h @@ -0,0 +1,44 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: RosterAppInfo.h +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: An extended app_info. +//------------------------------------------------------------------------------ + +#ifndef ROSTER_APP_INFO_H +#define ROSTER_APP_INFO_H + +#include + +enum application_state { + APP_STATE_INVALID, + APP_STATE_PRE_REGISTERED, + APP_STATE_REGISTERED, +}; + +struct RosterAppInfo : app_info { + application_state state; + + RosterAppInfo(); +}; + +#endif // ROSTER_APP_INFO_H diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp new file mode 100644 index 0000000000..2584f8dbd6 --- /dev/null +++ b/src/servers/registrar/TRoster.cpp @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: TRoster.cpp +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: TRoster is the incarnation of The Roster. It manages the +// running applications. +//------------------------------------------------------------------------------ + +#include "TRoster.h" + +// constructor +TRoster::TRoster() + : fInfos() +{ +} + +// destructor +TRoster::~TRoster() +{ +} + +// HandleAddApplication +void +TRoster::HandleAddApplication(BMessage *message) +{ +} + +// HandleCompleteRegistration +void +TRoster::HandleCompleteRegistration(BMessage *message) +{ +} + +// HandleIsAppPreRegistered +void +TRoster::HandleIsAppPreRegistered(BMessage *message) +{ +} + +// HandleRemovePreRegApp +void +TRoster::HandleRemovePreRegApp(BMessage *message) +{ +} + +// HandleRemoveApp +void +TRoster::HandleRemoveApp(BMessage *message) +{ +} + diff --git a/src/servers/registrar/TRoster.h b/src/servers/registrar/TRoster.h new file mode 100644 index 0000000000..6524e3f2c7 --- /dev/null +++ b/src/servers/registrar/TRoster.h @@ -0,0 +1,61 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: TRoster.h +// Author: Ingo Weinhold (bonefish@users.sf.net) +// Description: TRoster is the incarnation of The Roster. It manages the +// running applications. +//------------------------------------------------------------------------------ + +#ifndef T_ROSTER_H +#define T_ROSTER_H + +#include + +#include "AppInfoList.h" + +class BMessage; + +// For strategic reasons, as TRoster appears in the BMessenger header. +namespace BPrivate { + +class TRoster { +public: + TRoster(); + virtual ~TRoster(); + + void HandleAddApplication(BMessage *message); + void HandleCompleteRegistration(BMessage *message); + void HandleIsAppPreRegistered(BMessage *message); + void HandleRemovePreRegApp(BMessage *message); + void HandleRemoveApp(BMessage *message); + +private: + AppInfoList fInfos; +}; + +}; // namespace BPrivate + +// Only the registrar code uses this header. No need to hide TRoster in the +// namespace. +using BPrivate::TRoster; + +#endif // T_ROSTER_H