1 /* 2 * Copyright 2013-2017 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Adrien Destugues, pulkomandy@pulkomandy.tk 7 */ 8 9 10 #include <UrlResult.h> 11 12 13 #ifndef LIBNETAPI_DEPRECATED 14 using namespace BPrivate::Network; 15 #endif 16 17 BUrlResult::BUrlResult() 18 : 19 BArchivable(), 20 fContentType(), 21 fLength(0) 22 { 23 } 24 25 26 BUrlResult::BUrlResult(BMessage* archive) 27 : 28 BArchivable(archive) 29 { 30 fContentType = archive->FindString("ContentType"); 31 fLength = archive->FindInt32("Length"); 32 } 33 34 35 BUrlResult::~BUrlResult() 36 { 37 } 38 39 40 status_t 41 BUrlResult::Archive(BMessage* archive, bool deep) const 42 { 43 status_t result = BArchivable::Archive(archive, deep); 44 45 if (result != B_OK) 46 return result; 47 48 archive->AddString("ContentType", fContentType); 49 archive->AddInt32("Length", fLength); 50 51 return B_OK; 52 } 53 54 55 void 56 BUrlResult::SetContentType(BString contentType) 57 { 58 fContentType = contentType; 59 } 60 61 62 void 63 BUrlResult::SetLength(size_t length) 64 { 65 fLength = length; 66 } 67 68 69 BString 70 BUrlResult::ContentType() const 71 { 72 return fContentType; 73 } 74 75 76 size_t 77 BUrlResult::Length() const 78 { 79 return fLength; 80 } 81 82 83 /*static*/ BArchivable* 84 BUrlResult::Instantiate(BMessage* archive) 85 { 86 if (!validate_instantiation(archive, "BUrlResult")) 87 return NULL; 88 return new BUrlResult(archive); 89 } 90