[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: KRun confusion
From:       Brad Hards <bhards () bigpond ! net ! au>
Date:       2004-03-12 9:52:20
Message-ID: 200403122052.36441.bhards () bigpond ! net ! au
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 12 Mar 2004 08:27 am, Waldo Bastian wrote:
> All the action happens from the event loop, a sleep() will not be doing
> anything. If you haven't started the event loop yet you can do so with
> kapp->exec();
Ah, that might help.
<some time later>
Nope. My code just hangs at the time of the kapp.exec(). I've tried it before 
and after the KRun, but it just isn't happening for me.

I've attached the whole thing - it reads in a file format that Sony uses for 
doing direct reads from a memory stick within a video projector (when you 
don't have a PC attached). I need this to check my "export from KPresenter" 
code, when its written :-)

If anyone sees what is blatantly wrong, I'd like any feedback...

Brad
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAUYhjGwwszQ/PZzgRAsVFAJ9i/LqGKhjwsaKO2I0fW3ZhezqiKwCgjb81
A+TOVcQ3EGCOjoZIJN74Mnk=
=iG7H
-----END PGP SIGNATURE-----

["main.cpp" (text/x-c++src)]

/***************************************************************************
 *   Copyright (C) 2004 by Brad Hards                                      *
 *   bhards@bigpond.net.au                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <krun.h>
#include <kurl.h>
#include <klocale.h>
#include <kdebug.h>
#include <qdatastream.h>
#include <qfile.h>

static const char description[] =
    I18N_NOOP("Sony projector slideshow viewer");

static const char version[] = "0.1";

static KCmdLineOptions options[] =
{
    { "+filename", I18N_NOOP( "Document to open." ), 0 },
    { "+path", I18N_NOOP( "path to images" ), 0 },
    KCmdLineLastOption
};

void checkIsNull(char * array, int count)
{
	for (int i = 0; i < count; i++) {
		if (!(0 == array[i])) {
			kdWarning(0) << "Got non-null at offset" << i << endl;
		}
	}
}

int main(int argc, char **argv)
{
    KAboutData about("viewsonyslideshow", I18N_NOOP("viewsonyslideshow"), version, description,
                     KAboutData::License_GPL, "(C) 2004 Brad Hards", 0, 0, "bhards@bigpond.net.au");
    about.addAuthor( "Brad Hards", 0, "bhards@bigpond.net.au" );
    KCmdLineArgs::init(argc, argv, &about);
    KCmdLineArgs::addCmdLineOptions( options );
    KApplication app;
    /// viewsonyslideshow *mainWin = 0;

    if (app.isRestored())
    {
        /// RESTORE(viewsonyslideshow);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
	QFile file( args->arg(0) );

	bool result = file.open( IO_ReadOnly );
	if (false == result) {
		kdError(0) << "Couldn't open" << endl;
	}

	QDataStream stream( &file );
	stream.setByteOrder(QDataStream::LittleEndian);
	
	char buff[16385];
	stream.readRawBytes(buff, 16);

	QString magic = QString(buff);
	kdDebug(0) << "Magic: " << magic << endl; 
        
	QString version = QString(&(buff[8]));
	kdDebug(0) << "Version: " << version << endl;

	Q_UINT32 num_slides;
	stream >> num_slides;
	kdDebug(0) << "Number of real slides: " << num_slides << endl;

	stream.readRawBytes(buff, 68);
	QString dirPath = QString(buff);
	kdDebug(0) << "Path: " << dirPath << endl;

	Q_UINT32 int1;
	stream >> int1;
	if ( !(1 == int1) )
		kdDebug(0) << "Expecting 1: " << int1 << endl;
	Q_UINT32 int5;
	stream >> int5;
	if ( !(5 == int5) )
		kdDebug(0) << "Expecting 5: " << int5 << endl;

	stream.readRawBytes(buff, 24);
	checkIsNull(buff,24);
	
	stream.readRawBytes(buff, 16);
	QString title1 = QString(buff);
	kdDebug(0) << "Title1: " << title1 << endl;
	
	stream.readRawBytes(buff, 16);
	QString title2 = QString(buff);
	kdDebug(0) << "Title2: " << title2 << endl;

	stream.readRawBytes(buff, 44);
	QString typeface = QString(buff);
	kdDebug(0) << "Type face: " << typeface << endl;	

	Q_UINT32 unknown1;
	stream >> unknown1;
	if (! (0xffff0000 == unknown1))
		kdDebug(0) << "Unknown1: " << unknown1 << endl;
	
	Q_UINT32 unknown2;
	stream >> unknown2;
	if (! (0xffff00ff == unknown2))
		kdDebug(0) << "Unknown2: " << unknown2 << endl;
	
	Q_UINT32 unknown3;
	stream >> unknown3;
	if (! (0xffff00ff == unknown3))
		kdDebug(0) << "Unknown3: " << unknown3 << endl;

	Q_UINT32 unknown4;
	stream >> unknown4;
	if (! (0x000000ff == unknown4))
		kdDebug(0) << "Unknown4: " << unknown4 << endl;
	
	Q_UINT32 unknown5;
	stream >> unknown5;
	if (! (0x00000002 == unknown5))
		kdDebug(0) << "Unknown5: " << unknown5 << endl;	

	stream.readRawBytes(buff, 296);
	checkIsNull(buff, 296);

	app.exec();
	
	for (unsigned int i = 0; i < num_slides; i++) {
		stream.readRawBytes(buff, 64);
		QString slidePath = QString( args->arg(1) ) + dirPath
					   + QString("/") + QString(buff);
		kdDebug(0) << slidePath << endl;
		KURL url(slidePath);
		(void) new KRun(url);
	}

	// app.exec();
	
	args->clear();
    }

    return true;
}


["Makefile.am" (text/x-makefile)]

# set the include path for X, qt and KDE
INCLUDES = $(all_includes)

# let automoc handle all of the meta source files (moc)
METASOURCES = AUTO

messages: rc.cpp
	$(XGETTEXT) *.cpp -o $(podir)/viewsonyslideshow.pot

KDE_ICON = viewsonyslideshow

#########################################################################
# APPLICATION SECTION
#########################################################################
# this is the program that gets installed.  it's name is used for all
# of the other Makefile.am variables
bin_PROGRAMS = viewsonyslideshow

# the application source, library search path, and link libraries
viewsonyslideshow_SOURCES = main.cpp
viewsonyslideshow_LDFLAGS = $(KDE_RPATH) $(all_libraries)
viewsonyslideshow_LDADD = $(LIB_KDEUI) $(LIB_KIO)

# this is where the desktop file will go 
shelldesktopdir   = $(kde_appsdir)/Utilities
shelldesktop_DATA = viewsonyslideshow.desktop




>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic