home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
v
/
vista
/
c
/
datasave
< prev
next >
Wrap
Text File
|
1996-02-01
|
4KB
|
105 lines
// **************************************************************************
// Copyright 1996 David Allison
//
// VV VV IIIIII SSSSS TTTTTT AA
// VV VV II SS TT AA AA
// VV VV II SSSS TT AA AA
// VV VV II SS TT AAAAAAAA
// VV IIIIII SSSS TT AA AA
//
// MULTI-THREADED C++ WIMP CLASS LIBRARY
// for RISC OS
// **************************************************************************
//
// P U B L I C D O M A I N L I C E N C E
// -------------------------------------------
//
// This library is copyright. You may not sell the library for
// profit, but you may sell products which use it providing
// those products are presented as executable code and are not
// libraries themselves. The library is supplied without any
// warranty and the copyright owner cannot be held responsible for
// damage resulting from failure of any part of this library.
//
// See the User Manual for details of the licence.
//
// *************************************************************************
//
// datasave protocol
//
#include "Vista:task.h"
#include "Vista:datasave.h"
#include <string.h>
DataSave::DataSave(Task *task)
: Channel (task, "DataSave")
{
task->add_receiver (this, Task::Message_DataSave) ;
task->add_receiver (this, Task::Message_DataLoad) ;
task->add_receiver (this, Task::Message_DataSaveAck) ;
task->add_receiver (this, Task::Message_DataLoadAck) ;
my_ref = 0 ;
}
DataSave::~DataSave()
{
task->remove_receiver (this, Task::Message_DataSave) ;
task->remove_receiver (this, Task::Message_DataLoad) ;
task->remove_receiver (this, Task::Message_DataSaveAck) ;
task->remove_receiver (this, Task::Message_DataLoadAck) ;
}
void DataSave::save (int window, int icon, int x, int y, char *leaf)
{
throw ("Attempt to save using raw DataSave class - derive a new class") ;
}
void DataSave::save (char *path)
{
throw ("Attempt to save using raw DataSave class - derive a new class") ;
}
int DataSave::accept (int your_ref)
{
return my_ref == your_ref ;
}
void DataSave::datasave (int window, int icon, int x, int y, int est_size, int filetype, char *leaf)
{
int buf[256/sizeof(int)] ;
buf[0] = window ;
buf[1] = icon ;
buf[2] = x ;
buf[3] = y ;
buf[4] = est_size ;
buf[5] = filetype ;
strcpy ((char*)&buf[6], leaf) ;
int len = strlen (leaf) + 25 ;
task->send_message (Task::ESEND, Task::Message_DataSave, window, my_ref, 0, len,buf) ;
}
void DataSave::dataload (int task, int my_ref, int your_ref, int data_length, void *data)
{
this->task->send_message (Task::ESEND, Task::Message_DataLoad, task, my_ref, your_ref, data_length, data) ;
this->my_ref = 0 ; // reset reference
}
void DataSave::datasaveack (int my_ref, saveackdata *data, char *path)
{
strcpy (data->pathname, path) ;
int len = strlen (path) + 25 ;
task->send_message (Task::ESEND, Task::Message_DataSaveAck, data->window, my_ref, this->my_ref, len, data) ;
}
void DataSave::dataloadack (int task, int my_ref, int your_ref, int data_length, void *data)
{
this->task->send_message (Task::ESEND, Task::Message_DataLoadAck, task, my_ref, your_ref, data_length, data) ;
this->my_ref = 0 ; // reset reference
}