1/* 2 * Copyright 2013-2021, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Ingo Weinhold <ingo_weinhold@gmx.de> 7 * Stephan A��mus <superstippi@gmx.de> 8 * Rene Gollent <rene@gollent.com> 9 * Julian Harnath <julian.harnath@rwth-aachen.de> 10 * Andrew Lindesay <apl@lindesay.co.nz> 11 * 12 * Note that this file has been re-factored from `PackageManager.cpp` and 13 * authors have been carried across in 2021. 14 */ 15 16 17#include "DeskbarLink.h" 18 19#include "Logger.h" 20 21 22#define kPathKey "path" 23#define kLinkKey "link" 24 25 26DeskbarLink::DeskbarLink() 27{ 28} 29 30 31DeskbarLink::DeskbarLink(const BString& path, const BString& link) 32 : 33 fPath(path), 34 fLink(link) 35{ 36} 37 38 39DeskbarLink::DeskbarLink(const DeskbarLink& other) 40 : 41 fPath(other.fPath), 42 fLink(other.fLink) 43{ 44} 45 46 47DeskbarLink::DeskbarLink(BMessage* from) 48{ 49 if (from->FindString(kPathKey, &fPath) != B_OK) { 50 HDERROR("expected key [%s] in the message data when creating a " 51 "captcha", kPathKey); 52 } 53 54 if (from->FindString(kLinkKey, &fLink) != B_OK) { 55 HDERROR("expected key [%s] in the message data when creating a " 56 "captcha", kLinkKey); 57 } 58} 59 60 61 62DeskbarLink::~DeskbarLink() 63{ 64} 65 66 67const BString 68DeskbarLink::Path() const 69{ 70 return fPath; 71} 72 73 74const BString 75DeskbarLink::Link() const 76{ 77 return fLink; 78} 79 80 81status_t 82DeskbarLink::Archive(BMessage* into, bool deep) const 83{ 84 status_t result = B_OK; 85 if (result == B_OK && into == NULL) 86 result = B_ERROR; 87 if (result == B_OK) 88 result = into->AddString(kPathKey, fPath); 89 if (result == B_OK) 90 result = into->AddString(kLinkKey, fLink); 91 return result; 92} 93 94 95DeskbarLink& 96DeskbarLink::operator=(const DeskbarLink& other) 97{ 98 if (this == &other) 99 return *this; 100 fPath = other.Path(); 101 fLink = other.Link(); 102 return *this; 103} 104 105 106bool 107DeskbarLink::operator==(const DeskbarLink& other) 108{ 109 return fPath == other.fPath && fLink == other.fLink; 110} 111 112 113bool 114DeskbarLink::operator!=(const DeskbarLink& other) 115{ 116 return !(*this == other); 117} 118