#include <andrewos.h>
#include <class.h>
#include <sys/param.h>

#include <mhdb.ih>
#include <mhmlbox.eh>

boolean mhmailbox__InitializeObject(classid, self)
struct classheader *classid;
struct mhmailbox *self;
{
    self->sourcePath = NULL;
    return TRUE;
}

void mhmailbox__FinalizeObject(classid, self)
struct classheader *classid;
struct mhmailbox *self;
{
    if (self->sourcePath != NULL) {
	free(self->sourcePath);
    }
}

void mhmailbox__SetDatabase(self, database)
struct mhmailbox *self;
struct msgdatabase *database;
{
    super_SetDatabase(self, database);
}

void mhmailbox__SetSource(self, sourcePath)
struct mhmailbox *self;
char *sourcePath;
{
    if (self->sourcePath != NULL)  {
	free(self->sourcePath);
    }

    if (sourcePath == NULL)  {
	self->sourcePath = NULL;
    }
    else {
	char *newsourcePath = (char *) malloc(strlen(sourcePath) + 1);

	if (newsourcePath != NULL) {
	    strcpy(newsourcePath, sourcePath);
	}
	self->sourcePath = newsourcePath;
    }
}

char *mhmailbox__GetSource(self)
struct mhmailbox *self;
{
    return self->sourcePath;
}
