/***************************************************************************
                            Observer.m -  description
                             -------------------
    begin                : Fri Mar  8 13:55:08 2002
    copyright            : (C) 2000-2002 Lost Highway Ltd. All rights reserved.
    email                : Lost_Highway@tipitina.demon.co.uk
    generated by         : duke@tipitina on Fri Mar  8 13:55:08 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This library is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU Library General Public License as       *
 *   published by the Free Software Foundation; either version 2 of the    *
 *   License, or (at your option) any later version.                       *
 *                                                                         *
 ***************************************************************************/

#include <qtc/qt_QString.h>
#include <qtc/qt_QCString.h>
#include <kdec/kde_Observer.h>
#include <kdec/kde_DCOPObject.h>
#include <kdeobjc/KDESupport.h>
#include <kdeobjc/Observer.h>
#include <qtobjc/QByteArray.h>

#include <kdeobjc/Job.h>
#include <kdeobjc/KURL.h>


@implementation  Observer


- (int) newJob: (Job*)job showProgress: (BOOL)showProgress
{
	return (int) kde_Observer_newJob((kde_Observer *)[self qt], (kde_Job*) [job qt], (int)showProgress);
}

- jobFinished: (int)progressId
{
	kde_Observer_jobFinished((kde_Observer *)[self qt], (int)progressId);
	return self;
}

- (BOOL) openPassDlg: (NSString *)prompt user: (NSString *)user pass: (NSString *)pass readOnly: (BOOL)readOnly
{
static qt_QString * _qstring_pass = 0L;
static qt_QString * _qstring_user = 0L;
static qt_QString * _qstring_prompt = 0L;
	return (BOOL) kde_Observer_openPassDlg((kde_Observer *)[self qt], (qt_QString *) [prompt toQString: &_qstring_prompt], (qt_QString *) [user toQString: &_qstring_user], (qt_QString *) [pass toQString: &_qstring_pass], (int)readOnly);
}

//- (BOOL) openPassDlg: (AuthInfo*)info
//{
//	return (BOOL) kde_Observer_openPassDlg1((kde_Observer *)[self qt], (kde_AuthInfo*) [info qt]);
//}

- (int) messageBox: (int)progressId type: (int)type text: (NSString *)text caption: (NSString *)caption buttonYes: (NSString *)buttonYes buttonNo: (NSString *)buttonNo
{
static qt_QString * _qstring_buttonNo = 0L;
static qt_QString * _qstring_buttonYes = 0L;
static qt_QString * _qstring_caption = 0L;
static qt_QString * _qstring_text = 0L;
	return (int) kde_Observer_messageBox((kde_Observer *)[self qt], (int)progressId, (int)type, (qt_QString *) [text toQString: &_qstring_text], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString *) [buttonYes toQString: &_qstring_buttonYes], (qt_QString *) [buttonNo toQString: &_qstring_buttonNo]);
}

//- (int) open_RenameDlg: (Job*)job caption: (NSString *)caption src: (NSString *)src dest: (NSString *)dest mode: (int)mode newDest: (NSString *)newDest int: (int)arg1 int: (int)arg2 time_t: (time_t ctimeSrc  -1)arg3 time_t: (time_t ctimeDest  -1)arg4 time_t: (time_t mtimeSrc  -1)arg5 time_t: (time_t mtimeDest  -1)arg6
//{
//static qt_QString * _qstring_newDest = 0L;
//static qt_QString * _qstring_dest = 0L;
//static qt_QString * _qstring_src = 0L;
//static qt_QString * _qstring_caption = 0L;
//	return (int) kde_Observer_open_RenameDlg((kde_Observer *)[self qt], (kde_Job*) [job qt], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString *) [src toQString: &_qstring_src], (qt_QString *) [dest toQString: &_qstring_dest], (int)mode, (qt_QString *) [newDest toQString: &_qstring_newDest], (KIO::filesize_t sizeSrc (KIO::filesize_t) -1) arg1, (KIO::filesize_t sizeDest (KIO::filesize_t) -1) arg2, (time_t ctimeSrc  -1) arg3, (time_t ctimeDest  -1) arg4, (time_t mtimeSrc  -1) arg5, (time_t mtimeDest  -1) arg6);
//}

//- (int) open_RenameDlg: (Job*)job caption: (NSString *)caption src: (NSString *)src dest: (NSString *)dest mode: (int)mode newDest: (NSString *)newDest
//{
//static qt_QString * _qstring_newDest = 0L;
//static qt_QString * _qstring_dest = 0L;
//static qt_QString * _qstring_src = 0L;
//static qt_QString * _qstring_caption = 0L;
//	return (int) kde_Observer_open_RenameDlg((kde_Observer *)[self qt], (kde_Job*) [job qt], (qt_QString *) [caption toQString: &_qstring_caption], (qt_QString *) [src toQString: &_qstring_src], (qt_QString *) [dest toQString: &_qstring_dest], (int)mode, (qt_QString *) [newDest toQString: &_qstring_newDest], int, int, (time_t), (time_t), (time_t), (time_t));
//}

- (int) open_SkipDlg: (Job*)job multi: (BOOL)multi error_text: (NSString *)error_text
{
static qt_QString * _qstring_error_text = 0L;
	return (int) kde_Observer_open_SkipDlg((kde_Observer *)[self qt], (kde_Job*) [job qt], (int)multi, (qt_QString *) [error_text toQString: &_qstring_error_text]);
}

//- (k_dcop: /** * Called by the UI) Server: (using DCOP) if the user presses cancel* / void killJob( int)progressId
//{
//	return (k_dcop: /** * Called by the UI) kde_Observer_Server((kde_Observer *)[self qt], (using DCOP) if the user presses cancel* / void killJob( int) progressId);
//}

//- (int) metadata: (int)progressId
//{
//	return (int) kde_Observer_metadata((kde_Observer *)[self qt], (int)progressId);
//}

- stating: (Job*)arg1 url: (KURL*)url
{
	kde_Observer_stating((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (kde_KURL*) [url qt]);
	return self;
}

- mounting: (Job*)arg1 dev: (NSString *)dev point: (NSString *)point
{
static qt_QString * _qstring_point = 0L;
static qt_QString * _qstring_dev = 0L;
	kde_Observer_mounting((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (qt_QString *) [dev toQString: &_qstring_dev], (qt_QString *) [point toQString: &_qstring_point]);
	return self;
}

- unmounting: (Job*)arg1 point: (NSString *)point
{
static qt_QString * _qstring_point = 0L;
	kde_Observer_unmounting((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (qt_QString *) [point toQString: &_qstring_point]);
	return self;
}

//- slotTotalSize: (Job*)arg1 size: (unsigned long)size
//{
//	kde_Observer_slotTotalSize((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)size);
//	return self;
//}

- slotTotalFiles: (Job*)arg1 files: (unsigned long)files
{
	kde_Observer_slotTotalFiles((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)files);
	return self;
}

- slotTotalDirs: (Job*)arg1 dirs: (unsigned long)dirs
{
	kde_Observer_slotTotalDirs((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)dirs);
	return self;
}

//- slotProcessedSize: (Job*)arg1 size: (unsigned long)size
//{
//	kde_Observer_slotProcessedSize((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)size);
//	return self;
//}

- slotProcessedFiles: (Job*)arg1 files: (unsigned long)files
{
	kde_Observer_slotProcessedFiles((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)files);
	return self;
}

- slotProcessedDirs: (Job*)arg1 dirs: (unsigned long)dirs
{
	kde_Observer_slotProcessedDirs((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)dirs);
	return self;
}

- slotSpeed: (Job*)arg1 bytes_per_second: (unsigned long)bytes_per_second
{
	kde_Observer_slotSpeed((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)bytes_per_second);
	return self;
}

- slotPercent: (Job*)arg1 percent: (unsigned long)percent
{
	kde_Observer_slotPercent((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)percent);
	return self;
}

- slotInfoMessage: (Job*)arg1 msg: (NSString *)msg
{
static qt_QString * _qstring_msg = 0L;
	kde_Observer_slotInfoMessage((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (qt_QString *) [msg toQString: &_qstring_msg]);
	return self;
}

- slotCopying: (Job*)arg1 from: (KURL*)from to: (KURL*)to
{
	kde_Observer_slotCopying((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (kde_KURL*) [from qt], (kde_KURL*) [to qt]);
	return self;
}

- slotMoving: (Job*)arg1 from: (KURL*)from to: (KURL*)to
{
	kde_Observer_slotMoving((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (kde_KURL*) [from qt], (kde_KURL*) [to qt]);
	return self;
}

- slotDeleting: (Job*)arg1 url: (KURL*)url
{
	kde_Observer_slotDeleting((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (kde_KURL*) [url qt]);
	return self;
}

- slotCreatingDir: (Job*)arg1 dir: (KURL*)dir
{
	kde_Observer_slotCreatingDir((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (kde_KURL*) [dir qt]);
	return self;
}

//- slotCanResume: (Job*)arg1 offset: (unsigned long)offset
//{
//	kde_Observer_slotCanResume((kde_Observer *)[self qt], (kde_Job*) [arg1 qt], (unsigned long)offset);
//	return self;
//}

+ (Observer*) self
{
	return (Observer*) [QtSupport objectForQtKey: kde_Observer_self() withClass: [Observer class] allocatedInObjcWorld: YES];
}

- init
{
	if ([self qt] == 0L) {
		[self setQt: kde_new_Observer()];
		[self setAllocatedInObjcWorld: YES];
		[QtSupport setObject: self forQtKey: [self qt]];
	}
	[super init];
	return self;
}

- (void) dealloc
{
	if ([self qt] != 0L) {
		if ([self allocatedInObjcWorld] && [self parent] == nil) {
			kde_del_Observer((kde_Observer *)[self qt]);
		}
		[QtSupport removeQtKey: [self qt]];
		[self setQt: 0L];
	}
	[super dealloc];
}

@end

@implementation Observer (DCOPObjectImplementation)

- (NSString *) objId
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_DCOPObject_objId(kde_Observer_DCOPObject([self qt]));
	return [NSString fromQCString: _qcstring];
}

- (BOOL) setObjId: (NSString *)objId
{
static qt_QCString * _qcstring_objId = 0L;
	return (BOOL) kde_DCOPObject_setObjId(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [objId toQCString: &_qcstring_objId]);
}

- (BOOL) process: (NSString *)fun data: (QByteArray*)data replyType: (NSString *)replyType replyData: (QByteArray*)replyData
{
static qt_QCString * _qcstring_replyType = 0L;
static qt_QCString * _qcstring_fun = 0L;
	return (BOOL) kde_DCOPObject_process(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [fun toQCString: &_qcstring_fun], (qt_QByteArray*) [data qt], (qt_QCString*) [replyType toQCString: &_qcstring_replyType], (qt_QByteArray*) [replyData qt]);
}

- (BOOL) processDynamic: (NSString *)fun data: (QByteArray*)data replyType: (NSString *)replyType replyData: (QByteArray*)replyData
{
static qt_QCString * _qcstring_replyType = 0L;
static qt_QCString * _qcstring_fun = 0L;
	return (BOOL) kde_DCOPObject_processDynamic(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [fun toQCString: &_qcstring_fun], (qt_QByteArray*) [data qt], (qt_QCString*) [replyType toQCString: &_qcstring_replyType], (qt_QByteArray*) [replyData qt]);
}

- (NSArray *) functionsDynamic
{
static kde_QCStringList * _qlist = 0L;
	_qlist = kde_DCOPObject_functionsDynamic(kde_Observer_DCOPObject([self qt]));
	return (NSArray *) [NSMutableArray arrayWithQCStringList: _qlist];
}

- (NSArray *) interfacesDynamic
{
static kde_QCStringList * _qlist = 0L;
	_qlist = kde_DCOPObject_interfacesDynamic(kde_Observer_DCOPObject([self qt]));
	return (NSArray *) [NSMutableArray arrayWithQCStringList: _qlist];
}

- (NSArray *) interfaces
{
static kde_QCStringList * _qlist = 0L;
	_qlist = kde_DCOPObject_interfaces(kde_Observer_DCOPObject([self qt]));
	return (NSArray *) [NSMutableArray arrayWithQCStringList: _qlist];
}

- (NSArray *) functions
{
static kde_QCStringList * _qlist = 0L;
	_qlist = kde_DCOPObject_functions(kde_Observer_DCOPObject([self qt]));
	return (NSArray *) [NSMutableArray arrayWithQCStringList: _qlist];
}

- emitDCOPSignal: (NSString *)signal data: (QByteArray*)data
{
static qt_QCString * _qcstring_signal = 0L;
	kde_DCOPObject_emitDCOPSignal(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [signal toQCString: &_qcstring_signal], (qt_QByteArray*) [data qt]);
	return self;
}

- (BOOL) connectDCOPSignal: (NSString *)sender senderObj: (NSString *)senderObj signal: (NSString *)signal slot: (NSString *)slot Volatile: (BOOL)Volatile
{
static qt_QCString * _qcstring_slot = 0L;
static qt_QCString * _qcstring_signal = 0L;
static qt_QCString * _qcstring_senderObj = 0L;
static qt_QCString * _qcstring_sender = 0L;
	return (BOOL) kde_DCOPObject_connectDCOPSignal(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [sender toQCString: &_qcstring_sender], (qt_QCString*) [senderObj toQCString: &_qcstring_senderObj], (qt_QCString*) [signal toQCString: &_qcstring_signal], (qt_QCString*) [slot toQCString: &_qcstring_slot], (int)Volatile);
}

- (BOOL) disconnectDCOPSignal: (NSString *)sender senderObj: (NSString *)senderObj signal: (NSString *)signal slot: (NSString *)slot
{
static qt_QCString * _qcstring_slot = 0L;
static qt_QCString * _qcstring_signal = 0L;
static qt_QCString * _qcstring_senderObj = 0L;
static qt_QCString * _qcstring_sender = 0L;
	return (BOOL) kde_DCOPObject_disconnectDCOPSignal(kde_Observer_DCOPObject([self qt]), (qt_QCString*) [sender toQCString: &_qcstring_sender], (qt_QCString*) [senderObj toQCString: &_qcstring_senderObj], (qt_QCString*) [signal toQCString: &_qcstring_signal], (qt_QCString*) [slot toQCString: &_qcstring_slot]);
}

+ (BOOL) hasObject: (NSString *)objId
{
static qt_QCString * _qcstring_objId = 0L;
	return (BOOL) kde_DCOPObject_hasObject((qt_QCString*) [objId toQCString: &_qcstring_objId]);
}

+ (DCOPObject*) find: (NSString *)objId
{
static qt_QCString * _qcstring_objId = 0L;
	return (DCOPObject*) [QtSupport objectForQtKey: kde_DCOPObject_find((qt_QCString*) [objId toQCString: &_qcstring_objId]) withClass: [DCOPObject class] allocatedInObjcWorld: YES];
}

+ (NSString *) objectName: (QObject *)obj
{
static qt_QCString * _qcstring = 0L;
	_qcstring = kde_DCOPObject_objectName((qt_QObject *) [obj qt]);
	return [NSString fromQCString: _qcstring];
}
@end
