* Removed BONE PPP support.

* Coding style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33600 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-10-15 14:40:06 +00:00
parent 358b93352e
commit f802f04acf
1 changed files with 263 additions and 239 deletions

View File

@ -1,7 +1,12 @@
/* main - the daemon's inner workings
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
/*
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*
* Distributed under the terms of the MIT License.
*/
//! The daemon's inner workings
#include <Application.h>
@ -40,17 +45,6 @@
#include <MDRLanguage.h>
#ifndef HAIKU_TARGET_PLATFORM_BEOS // BONE and later have these, R5 doesn't.
#define BONE_SERIAL_PPP_GET_STATUS 0xbe230501
#define BSPPP_CONNECTED 4
typedef struct {
char if_name[32];
int connection_status;
status_t last_error;
int connect_speed;
} bsppp_status_t;
#include <unistd.h>
#endif
using std::map;
@ -59,66 +53,70 @@ typedef struct glorbal {
BStringList msgs;
} snuzzwut;
BMailStatusWindow *status;
static BMailStatusWindow* sStatus;
class MailDaemonApp : public BApplication {
public:
MailDaemonApp(void);
virtual ~MailDaemonApp();
public:
MailDaemonApp();
virtual ~MailDaemonApp();
virtual void MessageReceived(BMessage *msg);
virtual void RefsReceived(BMessage *a_message);
virtual void MessageReceived(BMessage* message);
virtual void RefsReceived(BMessage* message);
virtual void Pulse();
virtual bool QuitRequested();
virtual void ReadyToRun();
virtual void Pulse();
virtual bool QuitRequested();
virtual void ReadyToRun();
void InstallDeskbarIcon();
void RemoveDeskbarIcon();
void InstallDeskbarIcon();
void RemoveDeskbarIcon();
void RunChains(BList &list,BMessage *msg);
void SendPendingMessages(BMessage *msg);
void GetNewMessages(BMessage *msg);
void RunChains(BList& list, BMessage* message);
void SendPendingMessages(BMessage* message);
void GetNewMessages(BMessage* message);
private:
void UpdateAutoCheck(bigtime_t interval);
private:
void _UpdateAutoCheck(bigtime_t interval);
BMessageRunner *auto_check;
BMailSettings settings_file;
BMessageRunner* fAutoCheckRunner;
BMailSettings fSettingsFile;
int32 new_messages;
bool central_beep;
// TRUE to do a beep when the status window closes. This happens
// when all mail has been received, so you get one beep for
// everything rather than individual beeps for each mail account.
// Set to TRUE by the 'mcbp' message that the mail Notification
// filter sends us, cleared when the beep is done.
BList fetch_done_respondents;
int32 fNewMessages;
bool fCentralBeep;
// TRUE to do a beep when the status window closes. This happens
// when all mail has been received, so you get one beep for
// everything rather than individual beeps for each mail
// account.
// Set to TRUE by the 'mcbp' message that the mail Notification
// filter sends us, cleared when the beep is done.
BList fFetchDoneRespondents;
BList fQueries;
BList queries;
LEDAnimation *led;
LEDAnimation* fLEDAnimation;
BString alert_string;
BString fAlertString;
};
MailDaemonApp::MailDaemonApp(void)
: BApplication("application/x-vnd.Be-POST")
MailDaemonApp::MailDaemonApp()
:
BApplication("application/x-vnd.Be-POST")
{
status = new BMailStatusWindow(BRect(40, 400, 360, 400), "Mail Status",
settings_file.ShowStatusWindow());
auto_check = NULL;
sStatus = new BMailStatusWindow(BRect(40, 400, 360, 400), "Mail Status",
fSettingsFile.ShowStatusWindow());
fAutoCheckRunner = NULL;
}
MailDaemonApp::~MailDaemonApp()
{
delete auto_check;
delete fAutoCheckRunner;
for (int32 i = 0; i < queries.CountItems(); i++)
delete ((BQuery *)(queries.ItemAt(i)));
for (int32 i = 0; i < fQueries.CountItems(); i++)
delete (BQuery*)fQueries.ItemAt(i);
delete led;
delete fLEDAnimation;
}
@ -127,17 +125,17 @@ MailDaemonApp::ReadyToRun()
{
InstallDeskbarIcon();
UpdateAutoCheck(settings_file.AutoCheckInterval());
_UpdateAutoCheck(fSettingsFile.AutoCheckInterval());
BVolume volume;
BVolumeRoster roster;
new_messages = 0;
fNewMessages = 0;
while (roster.GetNextVolume(&volume) == B_OK) {
//{char name[255];volume.GetName(name);printf("Volume: %s\n",name);}
BQuery *query = new BQuery;
BQuery* query = new BQuery;
query->SetTarget(this);
query->SetVolume(&volume);
@ -155,38 +153,39 @@ MailDaemonApp::ReadyToRun()
query->Fetch();
BEntry entry;
for (; query->GetNextEntry(&entry) == B_OK; new_messages++);
while (query->GetNextEntry(&entry) == B_OK)
fNewMessages++;
queries.AddItem(query);
fQueries.AddItem(query);
}
BString string;
MDR_DIALECT_CHOICE(
if (new_messages > 0)
string << new_messages;
if (fNewMessages > 0)
string << fNewMessages;
else
string << "No";
if (new_messages != 1)
if (fNewMessages != 1)
string << " new messages.";
else
string << " new message.";,
if (new_messages > 0)
string << new_messages << " 通の未読メッセージがあります ";
if (fNewMessages > 0)
string << fNewMessages << " 通の未読メッセージがあります ";
else
string << "未読メッセージはありません";
);
central_beep = false;
status->SetDefaultMessage(string);
fCentralBeep = false;
sStatus->SetDefaultMessage(string);
led = new LEDAnimation;
fLEDAnimation = new LEDAnimation;
SetPulseRate(1000000);
}
void
MailDaemonApp::RefsReceived(BMessage *message)
MailDaemonApp::RefsReceived(BMessage* message)
{
status->Activate(true);
sStatus->Activate(true);
entry_ref ref;
for (int32 i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
@ -203,185 +202,186 @@ MailDaemonApp::RefsReceived(BMessage *message)
continue;
int32 size;
if (node.ReadAttr("MAIL:fullsize", B_SIZE_T_TYPE, 0, &size, sizeof(size)) < 0)
if (node.ReadAttr("MAIL:fullsize", B_SIZE_T_TYPE, 0, &size,
sizeof(size)) < 0) {
size = -1;
}
BPath path(&ref);
BMailChainRunner *runner = GetMailChainRunner(id, status);
runner->GetSingleMessage(uid.String(), size, &path);
BMailChainRunner* runner = GetMailChainRunner(id, sStatus);
if (runner != NULL)
runner->GetSingleMessage(uid.String(), size, &path);
}
}
void
MailDaemonApp::UpdateAutoCheck(bigtime_t interval)
MailDaemonApp::_UpdateAutoCheck(bigtime_t interval)
{
if (interval > 0) {
if (auto_check != NULL) {
auto_check->SetInterval(interval);
auto_check->SetCount(-1);
if (fAutoCheckRunner != NULL) {
fAutoCheckRunner->SetInterval(interval);
fAutoCheckRunner->SetCount(-1);
} else
auto_check = new BMessageRunner(be_app_messenger,new BMessage('moto'),interval);
fAutoCheckRunner = new BMessageRunner(be_app_messenger,
new BMessage('moto'), interval);
} else {
delete auto_check;
auto_check = NULL;
delete fAutoCheckRunner;
fAutoCheckRunner = NULL;
}
}
void
MailDaemonApp::MessageReceived(BMessage *msg)
MailDaemonApp::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case 'moto':
if (settings_file.CheckOnlyIfPPPUp()) {
#ifndef HAIKU_TARGET_PLATFORM_BEOS
int s = socket(AF_INET, SOCK_DGRAM, 0);
bsppp_status_t status;
strcpy(status.if_name, "ppp0");
if (ioctl(s, BONE_SERIAL_PPP_GET_STATUS, &status, sizeof(status)) != 0) {
close(s);
break;
} else {
if (status.connection_status != BSPPP_CONNECTED) {
close(s);
break;
}
}
close (s);
#else
if (find_thread("tty_thread") <= 0)
break;
#endif
if (fSettingsFile.CheckOnlyIfPPPUp()) {
// TODO: check whether internet is up and running!
}
// supposed to fall through
case 'mbth': // check & send messages
msg->what = 'msnd';
PostMessage(msg); //'msnd');
PostMessage(msg);
// supposed to fall trough
case 'mnow': // check messages
GetNewMessages(msg);
break;
case 'msnd': // send messages
SendPendingMessages(msg);
break;
case 'mrrs':
settings_file.Reload();
UpdateAutoCheck(settings_file.AutoCheckInterval());
status->SetShowCriterion(settings_file.ShowStatusWindow());
fSettingsFile.Reload();
_UpdateAutoCheck(fSettingsFile.AutoCheckInterval());
sStatus->SetShowCriterion(fSettingsFile.ShowStatusWindow());
break;
case 'shst': // when to show the status window
{
int32 mode;
if (msg->FindInt32("ShowStatusWindow",&mode) == B_OK)
status->SetShowCriterion(mode);
if (msg->FindInt32("ShowStatusWindow", &mode) == B_OK)
sStatus->SetShowCriterion(mode);
break;
}
case 'lkch': // status window look changed
case 'wsch': // workspace changed
status->PostMessage(msg);
sStatus->PostMessage(msg);
break;
case 'stwg': //----StaT Window Gone
{
BMessage *msg, reply('mnuc');
reply.AddInt32("num_new_messages",new_messages);
while((msg = (BMessage *)fetch_done_respondents.RemoveItem(0L))) {
case 'stwg': // Status window gone
{
BMessage reply('mnuc');
reply.AddInt32("num_new_messages", fNewMessages);
while ((msg = (BMessage*)fFetchDoneRespondents.RemoveItem(0L))) {
msg->SendReply(&reply);
delete msg;
}
}
if (alert_string != B_EMPTY_STRING) {
alert_string.Truncate(alert_string.Length()-1);
BAlert *alert = new BAlert(MDR_DIALECT_CHOICE ("New Messages","新着メッセージ"), alert_string.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL);
if (fAlertString != B_EMPTY_STRING) {
fAlertString.Truncate(fAlertString.Length() - 1);
BAlert* alert = new BAlert(MDR_DIALECT_CHOICE("New Messages",
"新着メッセージ"), fAlertString.String(), "OK", NULL, NULL,
B_WIDTH_AS_USUAL);
alert->SetFeel(B_NORMAL_WINDOW_FEEL);
alert->Go(NULL);
alert_string = B_EMPTY_STRING;
fAlertString = B_EMPTY_STRING;
}
if (central_beep) {
if (fCentralBeep) {
system_beep("New E-mail");
central_beep = false;
fCentralBeep = false;
}
break;
}
case 'mcbp':
if (new_messages > 0) {
central_beep = true;
}
if (fNewMessages > 0)
fCentralBeep = true;
break;
case 'mnum': //----Number of new messages
{
BMessage reply('mnuc' /* Mail NU message Count */);
case 'mnum': // Number of new messages
{
BMessage reply('mnuc'); // Mail New message Count
if (msg->FindBool("wait_for_fetch_done")) {
fetch_done_respondents.AddItem(DetachCurrentMessage());
fFetchDoneRespondents.AddItem(DetachCurrentMessage());
break;
}
reply.AddInt32("num_new_messages",new_messages);
reply.AddInt32("num_new_messages", fNewMessages);
msg->SendReply(&reply);
}
break;
case 'mblk': //-----Mail BLinK
if (new_messages > 0)
led->Start();
}
case 'mblk': // Mail Blink
if (fNewMessages > 0)
fLEDAnimation->Start();
break;
case 'enda': //-----End Auto Check
delete auto_check;
auto_check = NULL;
case 'enda': // End Auto Check
delete fAutoCheckRunner;
fAutoCheckRunner = NULL;
break;
case 'numg':
{
int32 num_messages = msg->FindInt32("num_messages");
MDR_DIALECT_CHOICE (
alert_string << num_messages << " new message";
if (num_messages > 1)
alert_string << 's';
{
int32 numMessages = msg->FindInt32("num_messages");
MDR_DIALECT_CHOICE(
fAlertString << numMessages << " new message";
if (numMessages > 1)
fAlertString << 's';
alert_string << " for " << msg->FindString("chain_name") << '\n';,
fAlertString << " for " << msg->FindString("chain_name")
<< '\n';,
alert_string << msg->FindString("chain_name") << "より\n" << num_messages
<< " 通のメッセージが届きました  ";
fAlertString << msg->FindString("chain_name") << "より\n"
<< numMessages << " 通のメッセージが届きました  ";
);
}
break;
}
case B_QUERY_UPDATE:
{
{
int32 what;
msg->FindInt32("opcode",&what);
msg->FindInt32("opcode", &what);
switch (what) {
case B_ENTRY_CREATED:
new_messages++;
fNewMessages++;
break;
case B_ENTRY_REMOVED:
new_messages--;
fNewMessages--;
break;
}
BString string;
MDR_DIALECT_CHOICE (
if (new_messages > 0)
string << new_messages;
MDR_DIALECT_CHOICE(
if (fNewMessages > 0)
string << fNewMessages;
else
string << "No";
if (new_messages != 1)
if (fNewMessages != 1)
string << " new messages.";
else
string << " new message.";,
if (new_messages > 0)
string << new_messages << " 通の未読メッセージがあります";
if (fNewMessages > 0)
string << fNewMessages << " 通の未読メッセージがあります";
else
string << "未読メッセージはありません";
);
status->SetDefaultMessage(string.String());
sStatus->SetDefaultMessage(string.String());
break;
}
}
default:
BApplication::MessageReceived(msg);
break;
}
BApplication::MessageReceived(msg);
}
@ -396,7 +396,8 @@ MailDaemonApp::InstallDeskbarIcon()
status_t status = roster.FindApp("application/x-vnd.Be-POST", &ref);
if (status < B_OK) {
fprintf(stderr, "Can't find application to tell deskbar: %s\n", strerror(status));
fprintf(stderr, "Can't find application to tell deskbar: %s\n",
strerror(status));
return;
}
@ -428,17 +429,17 @@ MailDaemonApp::QuitRequested()
void
MailDaemonApp::RunChains(BList &list, BMessage *msg)
MailDaemonApp::RunChains(BList& list, BMessage* msg)
{
BMailChain *chain;
BMailChain* chain;
int32 index = 0, id;
for (; msg->FindInt32("chain", index, &id) == B_OK; index++) {
for (int32 i = 0; i < list.CountItems(); i++) {
chain = (BMailChain *)list.ItemAt(i);
chain = (BMailChain*)list.ItemAt(i);
if (chain->ID() == (unsigned)id) {
chain->RunChain(status, true, false, true);
chain->RunChain(sStatus, true, false, true);
list.RemoveItem(i); // the chain runner deletes the chain
break;
}
@ -448,20 +449,20 @@ MailDaemonApp::RunChains(BList &list, BMessage *msg)
if (index == 0) {
// invoke all chains
for (int32 i = 0; i < list.CountItems(); i++) {
chain = (BMailChain *)list.ItemAt(i);
chain = (BMailChain*)list.ItemAt(i);
chain->RunChain(status, true, false, true);
chain->RunChain(sStatus, true, false, true);
}
} else {
// delete unused chains
for (int32 i = list.CountItems(); i-- > 0;)
delete (BMailChain *)list.RemoveItem(i);
delete (BMailChain*)list.RemoveItem(i);
}
}
void
MailDaemonApp::GetNewMessages(BMessage *msg)
MailDaemonApp::GetNewMessages(BMessage* msg)
{
BList list;
GetInboundMailChains(&list);
@ -471,7 +472,7 @@ MailDaemonApp::GetNewMessages(BMessage *msg)
void
MailDaemonApp::SendPendingMessages(BMessage *msg)
MailDaemonApp::SendPendingMessages(BMessage* msg)
{
BVolumeRoster roster;
BVolume volume;
@ -489,32 +490,32 @@ MailDaemonApp::SendPendingMessages(BMessage *msg)
query.PushOp(B_OR);
int32 chain_id = -1;
int32 chainID = -1;
if (msg->FindInt32("chain",&chain_id) == B_OK) {
if (msg->FindInt32("chain", &chainID) == B_OK) {
query.PushAttr("MAIL:chain");
query.PushInt32(chain_id);
query.PushInt32(chainID);
query.PushOp(B_EQ);
query.PushOp(B_AND);
} else {
chain_id = -1;
}
} else
chainID = -1;
if (!msg->HasString("message_path")) {
if (chain_id == -1) {
map <int32, snuzzwut *> messages;
if (chainID == -1) {
map<int32, snuzzwut*> messages;
query.Fetch();
BEntry entry;
BPath path;
BNode node;
int32 chain, default_chain(BMailSettings().DefaultOutboundChainID());
int32 chain;
int32 defaultChain(BMailSettings().DefaultOutboundChainID());
off_t size;
while (query.GetNextEntry(&entry) == B_OK) {
while (node.SetTo(&entry) == B_BUSY) snooze(100);
if (node.ReadAttr("MAIL:chain",B_INT32_TYPE,0,&chain,4) < B_OK)
chain = default_chain;
chain = defaultChain;
entry.GetPath(&path);
node.GetSize(&size);
if (messages[chain] == NULL) {
@ -526,12 +527,15 @@ MailDaemonApp::SendPendingMessages(BMessage *msg)
messages[chain]->bytes += size;
}
map<int32,snuzzwut *>::iterator iter = messages.begin();
map<int32,snuzzwut *>::iterator end = messages.end();
map<int32, snuzzwut*>::iterator iter = messages.begin();
map<int32, snuzzwut*>::iterator end = messages.end();
while (iter != end) {
if ((iter->first > 0) && (BMailChain(iter->first).ChainDirection() == outbound)) {
BMailChainRunner *runner = GetMailChainRunner(iter->first,status);
runner->GetMessages(&messages[iter->first]->msgs,messages[iter->first]->bytes);
if (iter->first > 0 && BMailChain(iter->first)
.ChainDirection() == outbound) {
BMailChainRunner* runner
= GetMailChainRunner(iter->first, sStatus);
runner->GetMessages(&messages[iter->first]->msgs,
messages[iter->first]->bytes);
delete messages[iter->first];
runner->Stop();
}
@ -556,19 +560,25 @@ MailDaemonApp::SendPendingMessages(BMessage *msg)
bytes += size;
}
BMailChainRunner *runner = GetMailChainRunner(chain_id,status);
runner->GetMessages(&ids,bytes);
BMailChainRunner* runner
= GetMailChainRunner(chainID, sStatus);
runner->GetMessages(&ids, bytes);
runner->Stop();
}
} else {
const char *path;
msg->FindString("message_path",&path);
const char* path;
if (msg->FindString("message_path", &path) != B_OK)
return;
off_t size;
if (BNode(path).GetSize(&size) != B_OK)
return;
BStringList ids;
ids += path;
off_t size;
BNode(path).GetSize(&size);
BMailChainRunner *runner = GetMailChainRunner(chain_id,status);
runner->GetMessages(&ids,size);
BMailChainRunner* runner = GetMailChainRunner(chainID, sStatus);
runner->GetMessages(&ids, size);
runner->Stop();
}
}
@ -579,21 +589,23 @@ void
MailDaemonApp::Pulse()
{
bigtime_t idle = idle_time();
if (led->IsRunning() && (idle < 100000))
led->Stop();
if (fLEDAnimation->IsRunning() && idle < 100000)
fLEDAnimation->Stop();
}
// #pragma mark -
void
makeIndices()
{
const char *stringIndices[] = { B_MAIL_ATTR_ACCOUNT,B_MAIL_ATTR_CC,
B_MAIL_ATTR_FROM,B_MAIL_ATTR_NAME,
B_MAIL_ATTR_PRIORITY,B_MAIL_ATTR_REPLY,
B_MAIL_ATTR_STATUS,B_MAIL_ATTR_SUBJECT,
B_MAIL_ATTR_TO,B_MAIL_ATTR_THREAD, NULL};
const char* stringIndices[] = {
B_MAIL_ATTR_ACCOUNT, B_MAIL_ATTR_CC, B_MAIL_ATTR_FROM, B_MAIL_ATTR_NAME,
B_MAIL_ATTR_PRIORITY, B_MAIL_ATTR_REPLY, B_MAIL_ATTR_STATUS,
B_MAIL_ATTR_SUBJECT, B_MAIL_ATTR_TO, B_MAIL_ATTR_THREAD,
NULL
};
// add mail indices for all devices capable of querying
@ -601,7 +613,8 @@ makeIndices()
dev_t device;
while ((device = next_dev(&cookie)) >= B_OK) {
fs_info info;
if (fs_stat_dev(device,&info) < 0 || (info.flags & B_FS_HAS_QUERY) == 0)
if (fs_stat_dev(device, &info) < 0
|| (info.flags & B_FS_HAS_QUERY) == 0)
continue;
// Work-around for misbehaviour of earlier versions - should be
@ -613,28 +626,30 @@ makeIndices()
&& indexInfo.type == B_STRING_TYPE)
fs_remove_index(device, B_MAIL_ATTR_FLAGS);
for (int32 i = 0;stringIndices[i];i++)
fs_create_index(device,stringIndices[i],B_STRING_TYPE,0);
for (int32 i = 0; stringIndices[i]; i++)
fs_create_index(device, stringIndices[i], B_STRING_TYPE, 0);
fs_create_index(device,"MAIL:draft", B_INT32_TYPE, 0);
fs_create_index(device,B_MAIL_ATTR_WHEN,B_INT32_TYPE,0);
fs_create_index(device,B_MAIL_ATTR_FLAGS,B_INT32_TYPE,0);
fs_create_index(device,"MAIL:chain",B_INT32_TYPE,0);
fs_create_index(device,"MAIL:pending_chain",B_INT32_TYPE,0);
fs_create_index(device, "MAIL:draft", B_INT32_TYPE, 0);
fs_create_index(device, B_MAIL_ATTR_WHEN, B_INT32_TYPE, 0);
fs_create_index(device, B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0);
fs_create_index(device, "MAIL:chain", B_INT32_TYPE, 0);
fs_create_index(device, "MAIL:pending_chain", B_INT32_TYPE, 0);
}
}
void
addAttribute(BMessage &msg,const char *name,const char *publicName,int32 type = B_STRING_TYPE,bool viewable = true,bool editable = false,int32 width = 200)
addAttribute(BMessage& msg, const char* name, const char* publicName,
int32 type = B_STRING_TYPE, bool viewable = true, bool editable = false,
int32 width = 200)
{
msg.AddString("attr:name",name);
msg.AddString("attr:public_name",publicName);
msg.AddInt32("attr:type",type);
msg.AddBool("attr:viewable",viewable);
msg.AddBool("attr:editable",editable);
msg.AddInt32("attr:width",width);
msg.AddInt32("attr:alignment",B_ALIGN_LEFT);
msg.AddString("attr:name", name);
msg.AddString("attr:public_name", publicName);
msg.AddInt32("attr:type", type);
msg.AddBool("attr:viewable", viewable);
msg.AddBool("attr:editable", editable);
msg.AddInt32("attr:width", width);
msg.AddInt32("attr:alignment", B_ALIGN_LEFT);
}
@ -645,15 +660,15 @@ makeMimeType(bool remakeMIMETypes)
// do a full rebuild from nothing, or just add on the new attributes that
// we support which the regular BeOS mail daemon didn't have.
const char *types[2] = {"text/x-email","text/x-partial-email"};
const char* types[2] = {"text/x-email", "text/x-partial-email"};
BMimeType mime;
BMessage info;
for (int i = 0; i < 2; i++) {
for (size_t i = 0; i < sizeof(types) / sizeof(types[0]); i++) {
info.MakeEmpty();
mime.SetTo(types[i]);
if (mime.InitCheck() != B_OK) {
fputs("could not init mime type.\n",stderr);
fputs("could not init mime type.\n", stderr);
return;
}
@ -664,17 +679,20 @@ makeMimeType(bool remakeMIMETypes)
// Set up the list of e-mail related attributes that Tracker will
// let you display in columns for e-mail messages.
addAttribute(info,B_MAIL_ATTR_NAME,"Name");
addAttribute(info,B_MAIL_ATTR_SUBJECT,"Subject");
addAttribute(info,B_MAIL_ATTR_TO,"To");
addAttribute(info,B_MAIL_ATTR_CC,"Cc");
addAttribute(info,B_MAIL_ATTR_FROM,"From");
addAttribute(info,B_MAIL_ATTR_REPLY,"Reply To");
addAttribute(info,B_MAIL_ATTR_STATUS,"Status");
addAttribute(info,B_MAIL_ATTR_PRIORITY,"Priority",B_STRING_TYPE,true,true,40);
addAttribute(info,B_MAIL_ATTR_WHEN,"When",B_TIME_TYPE,true,false,150);
addAttribute(info,B_MAIL_ATTR_THREAD,"Thread");
addAttribute(info,B_MAIL_ATTR_ACCOUNT,"Account",B_STRING_TYPE,true,false,100);
addAttribute(info, B_MAIL_ATTR_NAME, "Name");
addAttribute(info, B_MAIL_ATTR_SUBJECT, "Subject");
addAttribute(info, B_MAIL_ATTR_TO, "To");
addAttribute(info, B_MAIL_ATTR_CC, "Cc");
addAttribute(info, B_MAIL_ATTR_FROM, "From");
addAttribute(info, B_MAIL_ATTR_REPLY, "Reply To");
addAttribute(info, B_MAIL_ATTR_STATUS, "Status");
addAttribute(info, B_MAIL_ATTR_PRIORITY, "Priority", B_STRING_TYPE,
true, true, 40);
addAttribute(info, B_MAIL_ATTR_WHEN, "When", B_TIME_TYPE, true,
false, 150);
addAttribute(info, B_MAIL_ATTR_THREAD, "Thread");
addAttribute(info, B_MAIL_ATTR_ACCOUNT, "Account", B_STRING_TYPE,
true, false, 100);
mime.SetAttrInfo(&info);
if (i == 0) {
@ -687,26 +705,32 @@ makeMimeType(bool remakeMIMETypes)
mime.SetPreferredApp("application/x-vnd.Be-POST");
}
} else {
// Just add the e-mail related attribute types we use to the MIME system.
// Just add the e-mail related attribute types we use to the MIME
// system.
mime.GetAttrInfo(&info);
bool hasAccount = false, hasThread = false, hasSize = false;
const char *result;
for (int32 index = 0;info.FindString("attr:name",index,&result) == B_OK;index++) {
if (!strcmp(result,B_MAIL_ATTR_ACCOUNT))
bool hasAccount = false;
bool hasThread = false;
bool hasSize = false;
const char* result;
for (int32 index = 0; info.FindString("attr:name", index, &result)
== B_OK; index++) {
if (!strcmp(result, B_MAIL_ATTR_ACCOUNT))
hasAccount = true;
if (!strcmp(result,B_MAIL_ATTR_THREAD))
if (!strcmp(result, B_MAIL_ATTR_THREAD))
hasThread = true;
if (!strcmp(result,"MAIL:fullsize"))
if (!strcmp(result, "MAIL:fullsize"))
hasSize = true;
}
if (!hasAccount)
addAttribute(info,B_MAIL_ATTR_ACCOUNT,"Account",B_STRING_TYPE,true,false,100);
if (!hasAccount) {
addAttribute(info, B_MAIL_ATTR_ACCOUNT, "Account",
B_STRING_TYPE, true, false, 100);
}
if (!hasThread)
addAttribute(info,B_MAIL_ATTR_THREAD,"Thread");
addAttribute(info, B_MAIL_ATTR_THREAD, "Thread");
/*if (!hasSize)
addAttribute(info,"MAIL:fullsize","Message Size",B_SIZE_T_TYPE,true,false,100);*/
//--- Tracker can't display SIZT attributes. What a pain.
// TODO: Tracker can't display SIZT attributes. What a pain.
if (!hasAccount || !hasThread/* || !hasSize*/)
mime.SetAttrInfo(&info);
}
@ -716,7 +740,7 @@ makeMimeType(bool remakeMIMETypes)
int
main(int argc, const char **argv)
main(int argc, const char** argv)
{
bool remakeMIMETypes = false;