// DWBS ------------------------------------------------------------------ DWBS
//
// PLATFORM		: ALL
// PRODUCT		: BIT_DEMON
// VISIBILITY	: PUBLIC
//
// DWBS ------------------------------------------------------------------ DWBS

#ifndef BD_EXAMPLE_COMMON_LOBBY_H
#define BD_EXAMPLE_COMMON_LOBBY_H

#include <bdExample/bdExampleCommon/bdExampleCommon.h>

// auth
#if !defined BD_PLATFORM_XENON &&  !defined BD_PLATFORM_XBOX
#include <bdLobby/bdAuthService.h>
#include <bdLobby/bdLobbyCommon/bdAuthCommon.h>
#endif

#include <bdLobby/bdAuthTicket.h>

// lobby
#include <bdLobby/bdLobbyService.h>

// remote tasks
#include <bdLobby/bdRemoteTaskManager/bdRemoteTask.h>

// matchmaking
#include <bdLobby/bdMatchMaking/bdMatchMaking.h>
#include <bdLobby/bdMatchMaking/bdSessionCreateResult.h>

// stats
#include <bdLobby/bdStats/bdStats.h>

// profiles
#include <bdLobby/bdProfiles/bdProfiles.h>
#include <bdLobby/bdTeams/bdTeams.h>

// messaging
#include <bdLobby/bdMessageStore/bdLobbyMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdLobbyMessageType.h>
#include <bdLobby/bdMessageStore/bdLobbyMessageFactory.h>

#include <bdLobby/bdMessageStore/bdMessageTypes/bdChannelChatMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdChannelNotificationMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdFriendCustomMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdFriendSessionInvitationMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdFriendshipProposalMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdTeamCustomMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdTeamInvitationMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdTeamNotificationMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdTeamSessionInvitationMessage.h>
#include <bdLobby/bdMessageStore/bdMessageTypes/bdUserNotificationMessage.h>

// channel chat
#include <bdLobby/bdChannelChat/bdChannelInfo.h>
#include <bdLobby/bdChannelChat/bdGetChannelMembersResult.h>

// utilities
#include <bdExample/bdExampleCommonLobby/PrintableList.h>

#define BD_LOG_LEVEL "example"

#define START_KEY	BD_BUTTON1
#define START_TEXT	"Start: " BD_BUTTON1_DESC

#define SKIP_KEY	BD_BUTTON2
#define SKIP_TEXT	"Skip: " BD_BUTTON2_DESC

#define AUTH_ADDRESS	"auth.eval.v1.80.mmp3.demonware.net"
#define AUTH_PORT		(3074)

#define LSG_ADDRESS		"lobby.eval.v1.80.mmp3.demonware.net"
#define LSG_PORT		(3074)



#define DNS_LOOKUP_TIMEOUT (5.0f)

// Task status values used in examples
enum TaskStatus
{
	READY,
	PENDING,
	DONE,
	FAILED,
	SKIPPED
};

// Safe string handling

void BD_CALL IndexStrings(const bdNChar8 *const strings[], 
						  const bdUInt numStrings, 
						  const bdUInt index, 
						  bdString& dest);

// Lobby error code to string translation

void BD_CALL LobbyErrorCodeToString(const bdLobbyErrorCode code, 
									bdNChar8 *const buffer,
									const bdUWord bufferSize);

// Lobby message to string translation

void BD_CALL LobbyMessageTypeToString(const bdLobbyMessageType type,
									  bdNChar8 *const buffer,
									  const bdUWord bufferSize);

#ifndef BD_PLATFORM_XENON
// DNS lookups
TaskStatus BD_CALL StartGetHostByName(const bdNChar8 *const domainNameStr,
									  bdGetHostByName **getHostByName,
									  const bdInetAddr resolvedAddr);

TaskStatus BD_CALL PumpGetHostByName(bdGetHostByName **getHostByName,
									 bdInetAddr &resolvedAddr);

#endif //#ifndef BD_PLATFORM_XENON

// Remote tasks

TaskStatus BD_CALL CheckRemoteTaskStatus(bdRemoteTask *const remoteTask);

void BD_CALL CloseRemoteTask(bdRemoteTask **remoteTask);

// Safe service accessors

bdMatchMaking* BD_CALL GetMatchMaking();

bdStats* BD_CALL GetStats();

bdProfiles* BD_CALL GetProfiles();

bdFriends* BD_CALL GetFriends();

bdChannelChat* BD_CALL GetChannelChat();

bdTeams* BD_CALL GetTeams();

bdMessageStore* BD_CALL GetMessageStore();

bdTitleUtilities* BD_CALL GetTitleUtilities();

bdKeyArchive* BD_CALL GetKeyArchive();

// Common print functions

void BD_CALL printInfo(const bdChannelInfo& channelInfo,
					   bdNChar8 *buf,
					   const bdUInt length);

void BD_CALL printInfo(const bdGetChannelMembersResult::bdChannelMember& memberInfo,
					   bdNChar8 *buf,
					   const bdUInt length);

#endif // BD_EXAMPLE_COMMON_LOBBY_H
