Minor MailNotifier cleanup.
* Renamed to BMailNotifier, as it's part of the public API.
* Renamed Notifier.{cpp|h} to DefaultNotifier.{cpp|h} as that's the class it
implements.
* Made the mail counts uint32, and the byte counts uint64.
This commit is contained in:
@@ -21,18 +21,18 @@
|
||||
#include <MailSettings.h>
|
||||
|
||||
|
||||
class MailNotifier {
|
||||
class BMailNotifier {
|
||||
public:
|
||||
virtual ~MailNotifier() {}
|
||||
virtual ~BMailNotifier() {}
|
||||
|
||||
virtual MailNotifier* Clone() = 0;
|
||||
virtual BMailNotifier* Clone() = 0;
|
||||
|
||||
virtual void ShowError(const char* error) = 0;
|
||||
virtual void ShowMessage(const char* message) = 0;
|
||||
|
||||
virtual void SetTotalItems(int32 items) = 0;
|
||||
virtual void SetTotalItemsSize(int32 size) = 0;
|
||||
virtual void ReportProgress(int bytes, int messages,
|
||||
virtual void SetTotalItems(uint32 items) = 0;
|
||||
virtual void SetTotalItemsSize(uint64 size) = 0;
|
||||
virtual void ReportProgress(uint32 messages, uint64 bytes,
|
||||
const char* message = NULL) = 0;
|
||||
virtual void ResetProgress(const char* message = NULL) = 0;
|
||||
};
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
//! Does not delete handler
|
||||
bool RemoveHandler(BHandler* handler);
|
||||
|
||||
void SetMailNotifier(MailNotifier* mailNotifier);
|
||||
void SetMailNotifier(BMailNotifier* mailNotifier);
|
||||
|
||||
virtual void ShowError(const char* error);
|
||||
virtual void ShowMessage(const char* message);
|
||||
@@ -126,7 +126,7 @@ protected:
|
||||
void LoadFilters(MailAddonSettings& settings);
|
||||
|
||||
BMailAccountSettings fAccountSettings;
|
||||
MailNotifier* fMailNotifier;
|
||||
BMailNotifier* fMailNotifier;
|
||||
|
||||
private:
|
||||
MailFilter* _LoadFilter(AddonSettings* filterSettings);
|
||||
|
||||
@@ -185,7 +185,7 @@ MailProtocol::RemoveHandler(BHandler* handler)
|
||||
|
||||
|
||||
void
|
||||
MailProtocol::SetMailNotifier(MailNotifier* mailNotifier)
|
||||
MailProtocol::SetMailNotifier(BMailNotifier* mailNotifier)
|
||||
{
|
||||
delete fMailNotifier;
|
||||
fMailNotifier = mailNotifier;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright 2011, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011-2012, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "DefaultNotifier.h"
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <IconUtils.h>
|
||||
#include <MailDaemon.h>
|
||||
#include <Roster.h>
|
||||
|
||||
#include "Notifier.h"
|
||||
|
||||
|
||||
#undef B_TRANSLATION_CONTEXT
|
||||
#define B_TRANSLATION_CONTEXT "Notifier"
|
||||
@@ -30,12 +30,9 @@ DefaultNotifier::DefaultNotifier(const char* accountName, bool inbound,
|
||||
fTotalSize(0),
|
||||
fSizeDone(0)
|
||||
{
|
||||
BString desc;
|
||||
if (fIsInbound == true)
|
||||
desc << B_TRANSLATE("Fetching mail for %name");
|
||||
else
|
||||
desc << B_TRANSLATE("Sending mail for %name");
|
||||
desc.ReplaceFirst("%name", fAccountName);
|
||||
BString desc(fIsInbound ? B_TRANSLATE("Fetching mail for %name")
|
||||
: B_TRANSLATE("Sending mail for %name"));
|
||||
desc.ReplaceFirst("%name", fAccountName);
|
||||
|
||||
BString identifier;
|
||||
identifier << accountName << inbound;
|
||||
@@ -59,10 +56,11 @@ DefaultNotifier::~DefaultNotifier()
|
||||
}
|
||||
|
||||
|
||||
MailNotifier*
|
||||
BMailNotifier*
|
||||
DefaultNotifier::Clone()
|
||||
{
|
||||
return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow, fShowMode);
|
||||
return new DefaultNotifier(fAccountName, fIsInbound, fErrorWindow,
|
||||
fShowMode);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +79,7 @@ DefaultNotifier::ShowMessage(const char* message)
|
||||
|
||||
|
||||
void
|
||||
DefaultNotifier::SetTotalItems(int32 items)
|
||||
DefaultNotifier::SetTotalItems(uint32 items)
|
||||
{
|
||||
fTotalItems = items;
|
||||
BString progress;
|
||||
@@ -91,7 +89,7 @@ DefaultNotifier::SetTotalItems(int32 items)
|
||||
|
||||
|
||||
void
|
||||
DefaultNotifier::SetTotalItemsSize(int32 size)
|
||||
DefaultNotifier::SetTotalItemsSize(uint64 size)
|
||||
{
|
||||
fTotalSize = size;
|
||||
fNotification.SetProgress(fSizeDone / (float)fTotalSize);
|
||||
@@ -99,7 +97,8 @@ DefaultNotifier::SetTotalItemsSize(int32 size)
|
||||
|
||||
|
||||
void
|
||||
DefaultNotifier::ReportProgress(int bytes, int messages, const char* message)
|
||||
DefaultNotifier::ReportProgress(uint32 messages, uint64 bytes,
|
||||
const char* message)
|
||||
{
|
||||
fSizeDone += bytes;
|
||||
if (fTotalSize > 0)
|
||||
@@ -107,11 +106,10 @@ DefaultNotifier::ReportProgress(int bytes, int messages, const char* message)
|
||||
else if (fTotalItems > 0) {
|
||||
// No size information available
|
||||
// Report progress in terms of message count instead
|
||||
|
||||
fNotification.SetProgress(fItemsDone / (float)fTotalItems);
|
||||
} else {
|
||||
// No message count information either
|
||||
// TODO we should use a B_INFORMATION_NOTIFICATION here, but it is not
|
||||
// TODO: we should use a B_INFORMATION_NOTIFICATION here, but it is not
|
||||
// possible to change the BNotification type after creating it...
|
||||
fNotification.SetProgress(0);
|
||||
}
|
||||
@@ -119,7 +117,6 @@ DefaultNotifier::ReportProgress(int bytes, int messages, const char* message)
|
||||
fItemsDone += messages;
|
||||
|
||||
BString progress;
|
||||
|
||||
progress << message << "\t";
|
||||
|
||||
if (fTotalItems > 0)
|
||||
@@ -1,10 +1,10 @@
|
||||
/*
|
||||
* Copyright 2011, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011-2012, Haiku, Inc. All rights reserved.
|
||||
* Copyright 2011, Clemens Zeidler <haiku@clemens-zeidler.de>
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef NOTIFIER_H
|
||||
#define NOTIFIER_H
|
||||
#ifndef DEFAULT_NOTIFIER_H
|
||||
#define DEFAULT_NOTIFIER_H
|
||||
|
||||
|
||||
#include <Notification.h>
|
||||
@@ -16,21 +16,21 @@
|
||||
#include "StatusWindow.h"
|
||||
|
||||
|
||||
class DefaultNotifier : public MailNotifier {
|
||||
class DefaultNotifier : public BMailNotifier {
|
||||
public:
|
||||
DefaultNotifier(const char* accountName,
|
||||
bool inbound, ErrorLogWindow* errorWindow,
|
||||
uint32& showMode);
|
||||
~DefaultNotifier();
|
||||
|
||||
MailNotifier* Clone();
|
||||
BMailNotifier* Clone();
|
||||
|
||||
void ShowError(const char* error);
|
||||
void ShowMessage(const char* message);
|
||||
|
||||
void SetTotalItems(int32 items);
|
||||
void SetTotalItemsSize(int32 size);
|
||||
void ReportProgress(int bytes, int messages,
|
||||
void SetTotalItems(uint32 items);
|
||||
void SetTotalItemsSize(uint64 size);
|
||||
void ReportProgress(uint32 messages, uint64 bytes,
|
||||
const char* message = NULL);
|
||||
void ResetProgress(const char* message = NULL);
|
||||
|
||||
@@ -41,10 +41,11 @@ private:
|
||||
BNotification fNotification;
|
||||
uint32& fShowMode;
|
||||
|
||||
int fTotalItems;
|
||||
int fItemsDone;
|
||||
int fTotalSize;
|
||||
int fSizeDone;
|
||||
uint32 fTotalItems;
|
||||
uint32 fItemsDone;
|
||||
uint64 fTotalSize;
|
||||
uint64 fSizeDone;
|
||||
};
|
||||
|
||||
#endif //NOTIFIER_H
|
||||
|
||||
#endif // DEFAULT_NOTIFIER_H
|
||||
@@ -18,7 +18,7 @@ Server mail_daemon :
|
||||
LEDAnimation.cpp
|
||||
MailDaemon.cpp
|
||||
main.cpp
|
||||
Notifier.cpp
|
||||
DefaultNotifier.cpp
|
||||
: be libmail.so tracker localestub [ TargetLibstdc++ ]
|
||||
$(TARGET_NETWORK_LIBS)
|
||||
;
|
||||
@@ -28,5 +28,5 @@ DoCatalogs mail_daemon :
|
||||
:
|
||||
DeskbarView.cpp
|
||||
MailDaemon.cpp
|
||||
Notifier.cpp
|
||||
DefaultNotifier.cpp
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user