diff --git a/src/preferences/mail/AutoConfigWindow.cpp b/src/preferences/mail/AutoConfigWindow.cpp index ab27ad9a59..1405dd2988 100644 --- a/src/preferences/mail/AutoConfigWindow.cpp +++ b/src/preferences/mail/AutoConfigWindow.cpp @@ -42,7 +42,7 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent) B_FOLLOW_ALL_SIDES, B_NAVIGABLE); fRootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(fRootView); - + int32 buttonHeight = 25; int32 buttonWidth = 50; BRect buttonRect = Bounds(); @@ -51,27 +51,26 @@ AutoConfigWindow::AutoConfigWindow(BRect rect, ConfigWindow *parent) buttonRect.left = buttonRect.right - 2 * buttonWidth - 5; buttonRect.right = buttonRect.left + buttonWidth; fBackButton = new BButton(buttonRect, "back", B_TRANSLATE("Back"), - new BMessage(kBackMsg)); + new BMessage(kBackMsg)); fBackButton->SetEnabled(false); fRootView->AddChild(fBackButton); - + buttonRect.left+= 5 + buttonWidth; buttonRect.right = buttonRect.left + buttonWidth; fNextButton = new BButton(buttonRect, "ok", B_TRANSLATE("OK"), new BMessage(kOkMsg)); fNextButton->MakeDefault(true); fRootView->AddChild(fNextButton); - + fBoxRect = Bounds(); fBoxRect.InsetBy(5,5); fBoxRect.bottom-= buttonHeight + 5; - + fMainView = new AutoConfigView(fBoxRect, fAutoConfig); fMainView->SetLabel(B_TRANSLATE("Account settings")); fRootView->AddChild(fMainView); - + // Add a shortcut to close the window using Command-W AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); - } diff --git a/src/preferences/mail/ConfigWindow.cpp b/src/preferences/mail/ConfigWindow.cpp index 4fecc32856..366df29cd2 100644 --- a/src/preferences/mail/ConfigWindow.cpp +++ b/src/preferences/mail/ConfigWindow.cpp @@ -245,7 +245,8 @@ class AboutTextView : public BTextView SetFontAndColor(0,23,&font,B_FONT_SIZE); // center the view vertically - rect = TextRect(); rect.OffsetTo(0,(Bounds().Height() - TextHeight(0,42)) / 2); + rect = TextRect(); + rect.OffsetTo(0,(Bounds().Height() - TextHeight(0,42)) / 2); SetTextRect(rect); // set the link regions @@ -270,11 +271,14 @@ class AboutTextView : public BTextView BTextView::Draw(updateRect); BRect rect(fMail.Frame()); - StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2)); + StrokeLine(BPoint(rect.left,rect.bottom-2), + BPoint(rect.right,rect.bottom-2)); rect = fBugsite.Frame(); - StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2)); + StrokeLine(BPoint(rect.left,rect.bottom-2), + BPoint(rect.right,rect.bottom-2)); rect = fWebsite.Frame(); - StrokeLine(BPoint(rect.left,rect.bottom-2),BPoint(rect.right,rect.bottom-2)); + StrokeLine(BPoint(rect.left,rect.bottom-2), + BPoint(rect.right,rect.bottom-2)); } virtual void MouseDown(BPoint point) @@ -308,7 +312,6 @@ ConfigWindow::ConfigWindow() fSaveSettings(false) { // create controls - BRect rect(Bounds()); BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); diff --git a/src/preferences/mail/DNSQuery.cpp b/src/preferences/mail/DNSQuery.cpp index 43317547e2..d32d1bfe5b 100644 --- a/src/preferences/mail/DNSQuery.cpp +++ b/src/preferences/mail/DNSQuery.cpp @@ -94,29 +94,11 @@ BRawNetBuffer::ReadUint32(uint32& value) status_t BRawNetBuffer::ReadString(BString& string) { - if (fReadPosition >= fBuffer.BufferLength()) + string = ""; + size_t readed = _ReadStringAt(string, fReadPosition); + if (readed < 0) return B_ERROR; - - char* buffer = (char*)fBuffer.Buffer(); - buffer = &buffer[fReadPosition]; - - // if the string is compressed we have to follow the links to the - // sub strings - while (fReadPosition < fBuffer.BufferLength() && *buffer != 0) { - if (uint8(*buffer) == 192) { - // found a pointer mark - buffer++; - // pointer takes 2 byte - fReadPosition = fReadPosition + 1; - off_t pos = uint8(*buffer); - _ReadSubString(string, pos); - break; - } - string.Append(buffer, 1); - buffer++; - fReadPosition++; - } - fReadPosition++; + fReadPosition += readed; return B_OK; } @@ -140,13 +122,32 @@ BRawNetBuffer::_Init(const void* buf, size_t size) } -void -BRawNetBuffer::_ReadSubString(BString& string, off_t pos) +size_t +BRawNetBuffer::_ReadStringAt(BString& string, off_t pos) { - // sub strings have no links to other substrings so we can read it in one - // piece + if (pos >= fBuffer.BufferLength()) + return -1; + + size_t readed = 0; char* buffer = (char*)fBuffer.Buffer(); - string.Append(&buffer[pos]); + buffer = &buffer[pos]; + // if the string is compressed we have to follow the links to the + // sub strings + while (pos < fBuffer.BufferLength() && *buffer != 0) { + if (uint8(*buffer) == 192) { + // found a pointer mark + buffer++; + readed++; + off_t subPos = uint8(*buffer); + _ReadStringAt(string, subPos); + break; + } + string.Append(buffer, 1); + buffer++; + readed++; + } + readed++; + return readed; } diff --git a/src/preferences/mail/DNSQuery.h b/src/preferences/mail/DNSQuery.h index 7ddeeaede9..3f26be6ef2 100644 --- a/src/preferences/mail/DNSQuery.h +++ b/src/preferences/mail/DNSQuery.h @@ -42,7 +42,8 @@ public: private: void _Init(const void* buf, size_t size); - void _ReadSubString(BString& string, off_t pos); + size_t _ReadStringAt(BString& string, off_t pos); + off_t fWritePosition; off_t fReadPosition; BMallocIO fBuffer; diff --git a/src/preferences/mail/main.cpp b/src/preferences/mail/main.cpp index 43a1b7d1f3..c32b90a53e 100644 --- a/src/preferences/mail/main.cpp +++ b/src/preferences/mail/main.cpp @@ -1,46 +1,23 @@ -/* main - the application and startup code -** -** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. -*/ +/* + * Copyright 2011, Haiku, Inc. All rights reserved. + * Copyright 2011, Clemens Zeidler + * Distributed under the terms of the MIT License. + */ +#include + #include "ConfigWindow.h" -#include -#include -#include - - -class BCatalog; - -class MailConfigApp : public BApplication { - public: - MailConfigApp(); - ~MailConfigApp(); -}; - - -MailConfigApp::MailConfigApp() - : BApplication("application/x-vnd.Haiku-Mail") -{ - (new ConfigWindow())->Show(); -} - - -MailConfigApp::~MailConfigApp() -{ -} - - -// #pragma mark - - int -main(int argc,char **argv) +main(int argc, char** argv) { - (new MailConfigApp())->Run(); - delete be_app; + BApplication app("application/x-vnd.Haiku-Mail"); + BWindow* window = new ConfigWindow; + window->Show(); + + app.Run(); return 0; } -