From f0330c4aff4caf4b01f7a106f2d3c2b8c96ccc72 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 19 Mar 2010 17:29:10 +0000 Subject: [PATCH] Removed AreaLink, not used git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35914 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/AreaLink.h | 64 --------- src/kits/app/AreaLink.cpp | 230 --------------------------------- src/kits/app/Jamfile | 1 - 3 files changed, 295 deletions(-) delete mode 100644 headers/private/app/AreaLink.h delete mode 100644 src/kits/app/AreaLink.cpp diff --git a/headers/private/app/AreaLink.h b/headers/private/app/AreaLink.h deleted file mode 100644 index ec7114ba5e..0000000000 --- a/headers/private/app/AreaLink.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm, bpmagic@columbus.rr.com - */ -#ifndef AREALINK_H -#define AREALINK_H - - -#include -#include -#include - -class AreaLinkHeader; -class BPoint; - - -#define MAX_ATTACHMENT_SIZE 65535 // in bytes -#define SIZE_SIZE 2 // size of the size records in an AreaLink area - - -class AreaLink { - public: - AreaLink(area_id area, bool is_arealink_area = false); - AreaLink(); - ~AreaLink(); - - void SetTarget(area_id area, bool is_arealink_area = false); - area_id GetTarget() const { return fTarget; } - - void Attach(const void *data, size_t size); - inline void Attach(const int32 &data); - inline void Attach(const int16 &data); - inline void Attach(const int8 &data); - inline void Attach(const float &data); - inline void Attach(const bool &data); - inline void Attach(const rgb_color &data); - inline void Attach(const BRect &data); - inline void Attach(const BPoint &data); - - void MakeEmpty(); - void *ItemAt(const int32 index) const { return fAttachList->ItemAt(index); } - int32 CountAttachments() const { return fAttachList->CountItems(); } - void *BaseAddress() const { return (void *)fBaseAddress; } - - void Lock(); - void Unlock(); - bool IsLocked(); - - private: - void _ReadAttachments(); - - private: - BList *fAttachList; - area_id fTarget; - bool fAreaIsOk; - bool fHaveLock; - int8 *fBaseAddress; - AreaLinkHeader *fHeader; -}; - -#endif // AREALINK_H diff --git a/src/kits/app/AreaLink.cpp b/src/kits/app/AreaLink.cpp deleted file mode 100644 index bd093ed64f..0000000000 --- a/src/kits/app/AreaLink.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2001-2007, Haiku, Inc. All Rights Reserved. - * Distributed under the terms of the MIT License. - * - * Authors: - * DarkWyrm, bpmagic@columbus.rr.com - */ - - -#include "AreaLink.h" - -#include - -#include - -//#define AL_DEBUG -#ifdef AL_DEBUG -#include -#endif - - -class AreaLinkHeader { - public: - AreaLinkHeader() { MakeEmpty(); fLock = B_NAME_NOT_FOUND; } - - void SetAttachmentCount(uint32 size) { fAttachmentCount = size; } - uint32 GetAttachmentCount() const { return fAttachmentCount; } - - void SetAttachmentSize(uint32 size) { fAttachmentSize = size; } - uint32 GetAttachmentSize() const { return fAttachmentSize; } - - void AddAttachment(uint32 size) { fAttachmentSize += size; fAttachmentCount++; } - - void SetLockSem(sem_id sem) { fLock = sem; } - sem_id GetLockSem() const { return fLock; } - - void MakeEmpty() { fAttachmentCount = 0; fAttachmentSize = 0; } - area_info GetInfo() const { return fInfo; } - void SetInfo(const area_info &newInfo) { fInfo = newInfo; } - - private: - uint32 fAttachmentCount; - uint32 fAttachmentSize; - sem_id fLock; - area_info fInfo; -}; - - -// #pragma mark - - - -AreaLink::AreaLink(area_id area, bool isAreaLinkArea) - :fAttachList(new BList(0)), - fHaveLock(false) -{ - SetTarget(area, isAreaLinkArea); -} - - -AreaLink::AreaLink() - :fAttachList(new BList(0)), - fTarget(B_NAME_NOT_FOUND), - fAreaIsOk(false), - fHaveLock(false), - fBaseAddress(0), - fHeader(0) -{ -} - - -AreaLink::~AreaLink() -{ - delete fAttachList; -} - - -void -AreaLink::SetTarget(area_id area, bool isAreaLinkArea) -{ - area_info targetInfo; - - if (get_area_info(area, &targetInfo) == B_OK) { - fTarget = area; - fAreaIsOk = true; - fHeader = (AreaLinkHeader *)targetInfo.address; - - if (isAreaLinkArea) - _ReadAttachments(); - else { - fHeader->MakeEmpty(); - fHeader->SetInfo(targetInfo); - } - - fBaseAddress = (int8*)targetInfo.address; - fBaseAddress += sizeof(AreaLinkHeader); - } else { - fTarget = B_NAME_NOT_FOUND; - fAreaIsOk = false; - } -} - - -void -AreaLink::Attach(const void *data, size_t size) -{ - if (!data || size == 0) - return; - - Lock(); - - // Will the attachment fit? - if (fHeader->GetAttachmentSize() + size > fHeader->GetInfo().size) { - // Being it won't fit, resize the area to fit the thing - int32 pageNum = int32(fHeader->GetInfo().size / B_PAGE_SIZE); - resize_area(fTarget, pageNum + 1); - } - - // Our attachment will fit, so copy the data into the current location - // and increment the appropriate fHeader values - int8 *currentpointer = (int8*)BaseAddress(); - currentpointer += fHeader->GetAttachmentSize(); - memcpy(currentpointer, data, size); - - fAttachList->AddItem(currentpointer); - fHeader->AddAttachment(size); - - Unlock(); -} - - -void -AreaLink::Attach(const int32 &data) -{ - Attach(&data, sizeof(int32)); -} - - -void -AreaLink::Attach(const int16 &data) -{ - Attach(&data, sizeof(int16)); -} - - -void -AreaLink::Attach(const int8 &data) -{ - Attach(&data, sizeof(int8)); -} - - -void -AreaLink::Attach(const float &data) -{ - Attach(&data, sizeof(float)); -} - - -void -AreaLink::Attach(const bool &data) -{ - Attach(&data, sizeof(bool)); -} - - -void -AreaLink::Attach(const rgb_color &data) -{ - Attach(&data, sizeof(rgb_color)); -} - - -void -AreaLink::Attach(const BRect &data) -{ - Attach(&data, sizeof(BRect)); -} - - -void -AreaLink::Attach(const BPoint &data) -{ - Attach(&data, sizeof(BPoint)); -} - - -void -AreaLink::MakeEmpty() -{ - fAttachList->MakeEmpty(); - fHeader->MakeEmpty(); -} - - -void -AreaLink::_ReadAttachments() -{ - int8 *index = fBaseAddress; - uint16 size; - - for (uint32 i = 0; i < fHeader->GetAttachmentCount(); i++) { - size = *((int16*)index); - fBaseAddress += SIZE_SIZE; - fAttachList->AddItem(fBaseAddress); - fBaseAddress += size; - } -} - - -void -AreaLink::Lock() -{ - if (!fHaveLock) - acquire_sem(fHeader->GetLockSem()); -} - - -void -AreaLink::Unlock() -{ - if (fHaveLock) - release_sem(fHeader->GetLockSem()); -} - - -bool -AreaLink::IsLocked() -{ - return fHaveLock; -} diff --git a/src/kits/app/Jamfile b/src/kits/app/Jamfile index 9a79f4bfda..686116da44 100644 --- a/src/kits/app/Jamfile +++ b/src/kits/app/Jamfile @@ -27,7 +27,6 @@ MergeObject app_kit.o : Application.cpp AppMisc.cpp AppServerLink.cpp - AreaLink.cpp Cursor.cpp Clipboard.cpp DesktopLink.cpp