Added classes TRoster, RosterAppInfo and AppInfoList. TRoster will be the *The Roster*, but has currently only unimplemented hooks for the app registration functionality. More to come.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@409 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2002-07-23 23:38:57 +00:00
parent 762a48a083
commit f9fd58cc75
7 changed files with 400 additions and 0 deletions

View File

@ -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();
}

View File

@ -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 <List.h>
#include <OS.h>
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

View File

@ -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 :
<boot!home!config!lib>libopenbeos.so

View File

@ -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)
{
}

View File

@ -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 <Roster.h>
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

View File

@ -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)
{
}

View File

@ -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 <SupportDefs.h>
#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