Style (pointer & spaces/tabs)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38115 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2010-08-15 12:18:26 +00:00
parent be95e26df8
commit 372b00b0f7
+115 -40
View File
@@ -45,11 +45,14 @@ BMailComponent::BMailComponent(uint32 defaultCharSet)
{ {
} }
BMailComponent::~BMailComponent() BMailComponent::~BMailComponent()
{ {
} }
uint32 BMailComponent::ComponentType()
uint32
BMailComponent::ComponentType()
{ {
if (NULL != dynamic_cast<BAttributedMailAttachment*> (this)) if (NULL != dynamic_cast<BAttributedMailAttachment*> (this))
return B_MAIL_ATTRIBUTED_ATTACHMENT; return B_MAIL_ATTRIBUTED_ATTACHMENT;
@@ -70,9 +73,11 @@ uint32 BMailComponent::ComponentType()
return B_MAIL_SIMPLE_ATTACHMENT; return B_MAIL_SIMPLE_ATTACHMENT;
} }
BMailComponent *BMailComponent::WhatIsThis() {
switch (ComponentType()) BMailComponent*
BMailComponent::WhatIsThis()
{ {
switch (ComponentType()) {
case B_MAIL_SIMPLE_ATTACHMENT: case B_MAIL_SIMPLE_ATTACHMENT:
return new BSimpleMailAttachment; return new BSimpleMailAttachment;
case B_MAIL_ATTRIBUTED_ATTACHMENT: case B_MAIL_ATTRIBUTED_ATTACHMENT:
@@ -85,9 +90,13 @@ BMailComponent *BMailComponent::WhatIsThis() {
} }
} }
bool BMailComponent::IsAttachment() {
bool
BMailComponent::IsAttachment()
{
const char* disposition = HeaderField("Content-Disposition"); const char* disposition = HeaderField("Content-Disposition");
if ((disposition != NULL) && (strncasecmp(disposition,"Attachment",strlen("Attachment")) == 0)) if ((disposition != NULL)
&& (strncasecmp(disposition, "Attachment", strlen("Attachment")) == 0))
return true; return true;
BMessage header; BMessage header;
@@ -107,7 +116,10 @@ bool BMailComponent::IsAttachment() {
} }
void BMailComponent::SetHeaderField(const char *key, const char *value, uint32 charset, mail_encoding encoding, bool replace_existing) { void
BMailComponent::SetHeaderField(const char* key, const char* value,
uint32 charset, mail_encoding encoding, bool replace_existing)
{
if (replace_existing) if (replace_existing)
headers.RemoveName(key); headers.RemoveName(key);
if (value != NULL && value[0] != 0) // Empty or NULL strings mean delete header. if (value != NULL && value[0] != 0) // Empty or NULL strings mean delete header.
@@ -117,16 +129,19 @@ void BMailComponent::SetHeaderField(const char *key, const char *value, uint32 c
// the headers is the one which affects all the headers. There used to be // the headers is the one which affects all the headers. There used to be
// separate settings for each item in the headers, but it never actually // separate settings for each item in the headers, but it never actually
// worked (can't store multiple items of different types in a BMessage). // worked (can't store multiple items of different types in a BMessage).
if (charset != B_MAIL_NULL_CONVERSION && if (charset != B_MAIL_NULL_CONVERSION
headers.ReplaceInt32 (kHeaderCharsetString, charset) != B_OK) && headers.ReplaceInt32 (kHeaderCharsetString, charset) != B_OK)
headers.AddInt32(kHeaderCharsetString, charset); headers.AddInt32(kHeaderCharsetString, charset);
if (encoding != null_encoding && if (encoding != null_encoding
headers.ReplaceInt8 (kHeaderEncodingString, encoding) != B_OK) && headers.ReplaceInt8 (kHeaderEncodingString, encoding) != B_OK)
headers.AddInt8(kHeaderEncodingString, encoding); headers.AddInt8(kHeaderEncodingString, encoding);
} }
void BMailComponent::SetHeaderField(const char *key, BMessage *structure, bool replace_existing) { void
BMailComponent::SetHeaderField(const char* key, BMessage* structure,
bool replace_existing)
{
int32 charset = B_MAIL_NULL_CONVERSION; int32 charset = B_MAIL_NULL_CONVERSION;
int8 encoding = null_encoding; int8 encoding = null_encoding;
const char* unlabeled = "unlabeled"; const char* unlabeled = "unlabeled";
@@ -138,14 +153,15 @@ void BMailComponent::SetHeaderField(const char *key, BMessage *structure, bool r
if (structure->HasString(unlabeled)) if (structure->HasString(unlabeled))
value << structure->FindString(unlabeled) << "; "; value << structure->FindString(unlabeled) << "; ";
const char *name, *sub_val; const char* name;
const char* sub_val;
type_code type; type_code type;
for (int32 i = 0; structure->GetInfo(B_STRING_TYPE, i, for (int32 i = 0; structure->GetInfo(B_STRING_TYPE, i,
#if !defined(HAIKU_TARGET_PLATFORM_DANO) #if !defined(HAIKU_TARGET_PLATFORM_DANO)
(char**) (char**)
#endif #endif
&name,&type) == B_OK; i++) &name, &type) == B_OK; i++) {
{
if (strcasecmp(name, unlabeled) == 0) if (strcasecmp(name, unlabeled) == 0)
continue; continue;
@@ -167,20 +183,28 @@ void BMailComponent::SetHeaderField(const char *key, BMessage *structure, bool r
SetHeaderField(key, value.String(), (uint32) charset, (mail_encoding) encoding); SetHeaderField(key, value.String(), (uint32) charset, (mail_encoding) encoding);
} }
const char *BMailComponent::HeaderField(const char *key, int32 index) {
const char*
BMailComponent::HeaderField(const char* key, int32 index)
{
const char* string = NULL; const char* string = NULL;
headers.FindString(key, index, &string); headers.FindString(key, index, &string);
return string; return string;
} }
status_t BMailComponent::HeaderField(const char *key, BMessage *structure, int32 index) {
status_t
BMailComponent::HeaderField(const char* key, BMessage* structure, int32 index)
{
BString string = HeaderField(key, index); BString string = HeaderField(key, index);
if (string == "") if (string == "")
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
BString sub_cat,end_piece; BString sub_cat;
int32 i = 0, end = 0; BString end_piece;
int32 i = 0;
int32 end = 0;
// Break the header into parts, they're separated by semicolons, like this: // Break the header into parts, they're separated by semicolons, like this:
// Content-Type: multipart/mixed;boundary= "----=_NextPart_000_00AA_354DB459.5977A1CA" // Content-Type: multipart/mixed;boundary= "----=_NextPart_000_00AA_354DB459.5977A1CA"
@@ -231,11 +255,17 @@ status_t BMailComponent::HeaderField(const char *key, BMessage *structure, int32
return B_OK; return B_OK;
} }
status_t BMailComponent::RemoveHeader(const char *key) {
status_t
BMailComponent::RemoveHeader(const char* key)
{
return headers.RemoveName(key); return headers.RemoveName(key);
} }
const char *BMailComponent::HeaderAt(int32 index) {
const char*
BMailComponent::HeaderAt(int32 index)
{
#if defined(HAIKU_TARGET_PLATFORM_DANO) #if defined(HAIKU_TARGET_PLATFORM_DANO)
const const
#endif #endif
@@ -246,8 +276,20 @@ const char *BMailComponent::HeaderAt(int32 index) {
return name; return name;
} }
status_t BMailComponent::GetDecodedData(BPositionIO *) {return B_OK;}
status_t BMailComponent::SetDecodedData(BPositionIO *) {return B_OK;} status_t
BMailComponent::GetDecodedData(BPositionIO*)
{
return B_OK;
}
status_t
BMailComponent::SetDecodedData(BPositionIO*)
{
return B_OK;
}
status_t status_t
BMailComponent::SetToRFC822(BPositionIO* data, size_t /*length*/, bool /*parse_now*/) BMailComponent::SetToRFC822(BPositionIO* data, size_t /*length*/, bool /*parse_now*/)
@@ -260,10 +302,12 @@ BMailComponent::SetToRFC822(BPositionIO *data, size_t /*length*/, bool /*parse_n
status_t status_t
BMailComponent::RenderToRFC822(BPositionIO *render_to) { BMailComponent::RenderToRFC822(BPositionIO* render_to)
{
int32 charset = B_ISO15_CONVERSION; int32 charset = B_ISO15_CONVERSION;
int8 encoding = quoted_printable; int8 encoding = quoted_printable;
const char *key, *value; const char* key;
const char* value;
char* allocd; char* allocd;
ssize_t amountWritten; ssize_t amountWritten;
BString concat; BString concat;
@@ -288,7 +332,8 @@ BMailComponent::RenderToRFC822(BPositionIO *render_to) {
concat << key << ": "; concat << key << ": ";
concat.CapitalizeEachWord(); concat.CapitalizeEachWord();
concat.Append(allocd,utf8_to_rfc2047(&allocd, strlen(value), charset, encoding)); concat.Append(allocd, utf8_to_rfc2047(&allocd, strlen(value),
charset, encoding));
free(allocd); free(allocd);
FoldLineAtWhiteSpaceAndAddCRLF(concat); FoldLineAtWhiteSpaceAndAddCRLF(concat);
@@ -305,7 +350,9 @@ BMailComponent::RenderToRFC822(BPositionIO *render_to) {
} }
status_t BMailComponent::MIMEType(BMimeType *mime) { status_t
BMailComponent::MIMEType(BMimeType* mime)
{
bool foundBestHeader; bool foundBestHeader;
const char* boundaryString; const char* boundaryString;
unsigned int i; unsigned int i;
@@ -348,7 +395,8 @@ status_t BMailComponent::MIMEType(BMimeType *mime) {
// Some extra processing to convert mixed or upper case MIME types into // Some extra processing to convert mixed or upper case MIME types into
// lower case, since the BeOS R5 BMimeType is case sensitive (but OpenBeOS // lower case, since the BeOS R5 BMimeType is case sensitive (but OpenBeOS
// isn't). Also truncate the string if it is too long. // isn't). Also truncate the string if it is too long.
for (i = 0; i < sizeof (typeAsLowerCaseString) - 1 && typeAsString[i] != 0; i++) for (i = 0; i < sizeof(typeAsLowerCaseString) - 1
&& typeAsString[i] != 0; i++)
typeAsLowerCaseString[i] = tolower(typeAsString[i]); typeAsLowerCaseString[i] = tolower(typeAsString[i]);
typeAsLowerCaseString[i] = 0; typeAsLowerCaseString[i] = 0;
@@ -385,40 +433,59 @@ BTextMailComponent::BTextMailComponent(const char *text, uint32 defaultCharSet)
SetHeaderField("MIME-Version", "1.0"); SetHeaderField("MIME-Version", "1.0");
} }
BTextMailComponent::~BTextMailComponent() BTextMailComponent::~BTextMailComponent()
{ {
} }
void BTextMailComponent::SetEncoding(mail_encoding encoding, int32 charset) {
void
BTextMailComponent::SetEncoding(mail_encoding encoding, int32 charset)
{
this->encoding = encoding; this->encoding = encoding;
this->charset = charset; this->charset = charset;
} }
void BTextMailComponent::SetText(const char *text) {
void
BTextMailComponent::SetText(const char* text)
{
this->text.SetTo(text); this->text.SetTo(text);
raw_data = NULL; raw_data = NULL;
} }
void BTextMailComponent::AppendText(const char *text) {
void
BTextMailComponent::AppendText(const char* text)
{
ParseRaw(); ParseRaw();
this->text << text; this->text << text;
} }
const char *BTextMailComponent::Text() {
const char*
BTextMailComponent::Text()
{
ParseRaw(); ParseRaw();
return text.String(); return text.String();
} }
BString *BTextMailComponent::BStringText() {
BString*
BTextMailComponent::BStringText()
{
ParseRaw(); ParseRaw();
return &text; return &text;
} }
void BTextMailComponent::Quote(const char *message, const char *quote_style) {
void
BTextMailComponent::Quote(const char* message, const char* quote_style)
{
ParseRaw(); ParseRaw();
BString string; BString string;
@@ -430,7 +497,10 @@ void BTextMailComponent::Quote(const char *message, const char *quote_style) {
text.Prepend(string.String()); text.Prepend(string.String());
} }
status_t BTextMailComponent::GetDecodedData(BPositionIO *data) {
status_t
BTextMailComponent::GetDecodedData(BPositionIO* data)
{
ParseRaw(); ParseRaw();
if (data == NULL) if (data == NULL)
@@ -455,7 +525,10 @@ status_t BTextMailComponent::GetDecodedData(BPositionIO *data) {
return written >= 0 ? B_OK : written; return written >= 0 ? B_OK : written;
} }
status_t BTextMailComponent::SetDecodedData(BPositionIO *data) {
status_t
BTextMailComponent::SetDecodedData(BPositionIO* data)
{
char buffer[255]; char buffer[255];
size_t buf_len; size_t buf_len;
@@ -538,7 +611,8 @@ BTextMailComponent::ParseRaw()
// Change line ends from \r\n to just \n. Though this won't work properly // Change line ends from \r\n to just \n. Though this won't work properly
// for UTF-16 because \r takes up two bytes rather than one. // for UTF-16 because \r takes up two bytes rather than one.
char *dest, *src; char* dest;
char* src;
char* end = string + bytes; char* end = string + bytes;
for (dest = src = string; src < end; src++) { for (dest = src = string; src < end; src++) {
if (*src != '\r') if (*src != '\r')
@@ -562,7 +636,8 @@ BTextMailComponent::ParseRaw()
int32 state = 0; int32 state = 0;
int32 destLength = bytes * 3 /* in case it grows */ + 1 /* +1 so it isn't zero which crashes */; int32 destLength = bytes * 3 /* in case it grows */ + 1 /* +1 so it isn't zero which crashes */;
string = text.LockBuffer(destLength); string = text.LockBuffer(destLength);
mail_convert_to_utf8(charset, decoded.String(), &bytes, string, &destLength, &state); mail_convert_to_utf8(charset, decoded.String(), &bytes, string,
&destLength, &state);
if (destLength > 0) if (destLength > 0)
text.UnlockBuffer(destLength); text.UnlockBuffer(destLength);
else { else {
@@ -629,7 +704,8 @@ BTextMailComponent::RenderToRFC822(BPositionIO *render_to)
// original text. Multiplying by 5 should make more than enough space. // original text. Multiplying by 5 should make more than enough space.
char* raw = alt.LockBuffer(dest_len); char* raw = alt.LockBuffer(dest_len);
int32 state = 0; int32 state = 0;
mail_convert_from_utf8(charset,this->text.String(),&len,raw,&dest_len,&state); mail_convert_from_utf8(charset, this->text.String(), &len, raw,
&dest_len, &state);
alt.UnlockBuffer(dest_len); alt.UnlockBuffer(dest_len);
raw = modified.LockBuffer((alt.Length() * 3) + 1); raw = modified.LockBuffer((alt.Length() * 3) + 1);
@@ -657,8 +733,7 @@ BTextMailComponent::RenderToRFC822(BPositionIO *render_to)
// filter them out, shouldn't be any after the encoding stage. // filter them out, shouldn't be any after the encoding stage.
char* string = modified.LockBuffer(modified.Length()); char* string = modified.LockBuffer(modified.Length());
for (int32 i = modified.Length();i-- > 0;) for (int32 i = modified.Length(); i-- > 0;) {
{
if (string[i] != '\0') if (string[i] != '\0')
continue; continue;