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:
+115
-40
@@ -45,11 +45,14 @@ BMailComponent::BMailComponent(uint32 defaultCharSet)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BMailComponent::~BMailComponent()
|
||||
{
|
||||
}
|
||||
|
||||
uint32 BMailComponent::ComponentType()
|
||||
|
||||
uint32
|
||||
BMailComponent::ComponentType()
|
||||
{
|
||||
if (NULL != dynamic_cast<BAttributedMailAttachment*> (this))
|
||||
return B_MAIL_ATTRIBUTED_ATTACHMENT;
|
||||
@@ -70,9 +73,11 @@ uint32 BMailComponent::ComponentType()
|
||||
return B_MAIL_SIMPLE_ATTACHMENT;
|
||||
}
|
||||
|
||||
BMailComponent *BMailComponent::WhatIsThis() {
|
||||
switch (ComponentType())
|
||||
|
||||
BMailComponent*
|
||||
BMailComponent::WhatIsThis()
|
||||
{
|
||||
switch (ComponentType()) {
|
||||
case B_MAIL_SIMPLE_ATTACHMENT:
|
||||
return new BSimpleMailAttachment;
|
||||
case B_MAIL_ATTRIBUTED_ATTACHMENT:
|
||||
@@ -85,9 +90,13 @@ BMailComponent *BMailComponent::WhatIsThis() {
|
||||
}
|
||||
}
|
||||
|
||||
bool BMailComponent::IsAttachment() {
|
||||
|
||||
bool
|
||||
BMailComponent::IsAttachment()
|
||||
{
|
||||
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;
|
||||
|
||||
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)
|
||||
headers.RemoveName(key);
|
||||
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
|
||||
// separate settings for each item in the headers, but it never actually
|
||||
// worked (can't store multiple items of different types in a BMessage).
|
||||
if (charset != B_MAIL_NULL_CONVERSION &&
|
||||
headers.ReplaceInt32 (kHeaderCharsetString, charset) != B_OK)
|
||||
if (charset != B_MAIL_NULL_CONVERSION
|
||||
&& headers.ReplaceInt32 (kHeaderCharsetString, charset) != B_OK)
|
||||
headers.AddInt32(kHeaderCharsetString, charset);
|
||||
if (encoding != null_encoding &&
|
||||
headers.ReplaceInt8 (kHeaderEncodingString, encoding) != B_OK)
|
||||
if (encoding != null_encoding
|
||||
&& headers.ReplaceInt8 (kHeaderEncodingString, encoding) != B_OK)
|
||||
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;
|
||||
int8 encoding = null_encoding;
|
||||
const char* unlabeled = "unlabeled";
|
||||
@@ -138,14 +153,15 @@ void BMailComponent::SetHeaderField(const char *key, BMessage *structure, bool r
|
||||
if (structure->HasString(unlabeled))
|
||||
value << structure->FindString(unlabeled) << "; ";
|
||||
|
||||
const char *name, *sub_val;
|
||||
const char* name;
|
||||
const char* sub_val;
|
||||
type_code type;
|
||||
for (int32 i = 0; structure->GetInfo(B_STRING_TYPE, i,
|
||||
#if !defined(HAIKU_TARGET_PLATFORM_DANO)
|
||||
(char**)
|
||||
#endif
|
||||
&name,&type) == B_OK; i++)
|
||||
{
|
||||
&name, &type) == B_OK; i++) {
|
||||
|
||||
if (strcasecmp(name, unlabeled) == 0)
|
||||
continue;
|
||||
|
||||
@@ -167,20 +183,28 @@ void BMailComponent::SetHeaderField(const char *key, BMessage *structure, bool r
|
||||
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;
|
||||
|
||||
headers.FindString(key, index, &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);
|
||||
if (string == "")
|
||||
return B_NAME_NOT_FOUND;
|
||||
|
||||
BString sub_cat,end_piece;
|
||||
int32 i = 0, end = 0;
|
||||
BString sub_cat;
|
||||
BString end_piece;
|
||||
int32 i = 0;
|
||||
int32 end = 0;
|
||||
|
||||
// Break the header into parts, they're separated by semicolons, like this:
|
||||
// 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;
|
||||
}
|
||||
|
||||
status_t BMailComponent::RemoveHeader(const char *key) {
|
||||
|
||||
status_t
|
||||
BMailComponent::RemoveHeader(const char* key)
|
||||
{
|
||||
return headers.RemoveName(key);
|
||||
}
|
||||
|
||||
const char *BMailComponent::HeaderAt(int32 index) {
|
||||
|
||||
const char*
|
||||
BMailComponent::HeaderAt(int32 index)
|
||||
{
|
||||
#if defined(HAIKU_TARGET_PLATFORM_DANO)
|
||||
const
|
||||
#endif
|
||||
@@ -246,8 +276,20 @@ const char *BMailComponent::HeaderAt(int32 index) {
|
||||
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
|
||||
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
|
||||
BMailComponent::RenderToRFC822(BPositionIO *render_to) {
|
||||
BMailComponent::RenderToRFC822(BPositionIO* render_to)
|
||||
{
|
||||
int32 charset = B_ISO15_CONVERSION;
|
||||
int8 encoding = quoted_printable;
|
||||
const char *key, *value;
|
||||
const char* key;
|
||||
const char* value;
|
||||
char* allocd;
|
||||
ssize_t amountWritten;
|
||||
BString concat;
|
||||
@@ -288,7 +332,8 @@ BMailComponent::RenderToRFC822(BPositionIO *render_to) {
|
||||
concat << key << ": ";
|
||||
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);
|
||||
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;
|
||||
const char* boundaryString;
|
||||
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
|
||||
// lower case, since the BeOS R5 BMimeType is case sensitive (but OpenBeOS
|
||||
// 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] = 0;
|
||||
|
||||
@@ -385,40 +433,59 @@ BTextMailComponent::BTextMailComponent(const char *text, uint32 defaultCharSet)
|
||||
SetHeaderField("MIME-Version", "1.0");
|
||||
}
|
||||
|
||||
|
||||
BTextMailComponent::~BTextMailComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void BTextMailComponent::SetEncoding(mail_encoding encoding, int32 charset) {
|
||||
|
||||
void
|
||||
BTextMailComponent::SetEncoding(mail_encoding encoding, int32 charset)
|
||||
{
|
||||
this->encoding = encoding;
|
||||
this->charset = charset;
|
||||
}
|
||||
|
||||
void BTextMailComponent::SetText(const char *text) {
|
||||
|
||||
void
|
||||
BTextMailComponent::SetText(const char* text)
|
||||
{
|
||||
this->text.SetTo(text);
|
||||
|
||||
raw_data = NULL;
|
||||
}
|
||||
|
||||
void BTextMailComponent::AppendText(const char *text) {
|
||||
|
||||
void
|
||||
BTextMailComponent::AppendText(const char* text)
|
||||
{
|
||||
ParseRaw();
|
||||
|
||||
this->text << text;
|
||||
}
|
||||
|
||||
const char *BTextMailComponent::Text() {
|
||||
|
||||
const char*
|
||||
BTextMailComponent::Text()
|
||||
{
|
||||
ParseRaw();
|
||||
|
||||
return text.String();
|
||||
}
|
||||
|
||||
BString *BTextMailComponent::BStringText() {
|
||||
|
||||
BString*
|
||||
BTextMailComponent::BStringText()
|
||||
{
|
||||
ParseRaw();
|
||||
|
||||
return &text;
|
||||
}
|
||||
|
||||
void BTextMailComponent::Quote(const char *message, const char *quote_style) {
|
||||
|
||||
void
|
||||
BTextMailComponent::Quote(const char* message, const char* quote_style)
|
||||
{
|
||||
ParseRaw();
|
||||
|
||||
BString string;
|
||||
@@ -430,7 +497,10 @@ void BTextMailComponent::Quote(const char *message, const char *quote_style) {
|
||||
text.Prepend(string.String());
|
||||
}
|
||||
|
||||
status_t BTextMailComponent::GetDecodedData(BPositionIO *data) {
|
||||
|
||||
status_t
|
||||
BTextMailComponent::GetDecodedData(BPositionIO* data)
|
||||
{
|
||||
ParseRaw();
|
||||
|
||||
if (data == NULL)
|
||||
@@ -455,7 +525,10 @@ status_t BTextMailComponent::GetDecodedData(BPositionIO *data) {
|
||||
return written >= 0 ? B_OK : written;
|
||||
}
|
||||
|
||||
status_t BTextMailComponent::SetDecodedData(BPositionIO *data) {
|
||||
|
||||
status_t
|
||||
BTextMailComponent::SetDecodedData(BPositionIO* data)
|
||||
{
|
||||
char buffer[255];
|
||||
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
|
||||
// for UTF-16 because \r takes up two bytes rather than one.
|
||||
char *dest, *src;
|
||||
char* dest;
|
||||
char* src;
|
||||
char* end = string + bytes;
|
||||
for (dest = src = string; src < end; src++) {
|
||||
if (*src != '\r')
|
||||
@@ -562,7 +636,8 @@ BTextMailComponent::ParseRaw()
|
||||
int32 state = 0;
|
||||
int32 destLength = bytes * 3 /* in case it grows */ + 1 /* +1 so it isn't zero which crashes */;
|
||||
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)
|
||||
text.UnlockBuffer(destLength);
|
||||
else {
|
||||
@@ -629,7 +704,8 @@ BTextMailComponent::RenderToRFC822(BPositionIO *render_to)
|
||||
// original text. Multiplying by 5 should make more than enough space.
|
||||
char* raw = alt.LockBuffer(dest_len);
|
||||
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);
|
||||
|
||||
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.
|
||||
|
||||
char* string = modified.LockBuffer(modified.Length());
|
||||
for (int32 i = modified.Length();i-- > 0;)
|
||||
{
|
||||
for (int32 i = modified.Length(); i-- > 0;) {
|
||||
if (string[i] != '\0')
|
||||
continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user