![]() ![]() |
Aug 13 2005, 02:09 PM
Post
#1
|
|
|
Group: Members Posts: 1,213 Joined: 9-June 05 From: Gobi Desert, Mongolia Member No.: 7,306 |
need to know what mechanism triggers when you in sert the sd card, I want to auto move some *.pdb fils made by JPluckX from my sd card to my Documents directory.
|
|
|
|
Sep 23 2005, 10:47 AM
Post
#2
|
|
|
Group: Members Posts: 78 Joined: 28-January 04 From: clovis CA USA Member No.: 1,580 |
bam
QCOP is your friend here. Don't have the code in front of me, but when I get home will try to post here at this forum the Qtopia event you register and listen for to get media mounts/dismounts |
|
|
|
Sep 23 2005, 11:07 PM
Post
#3
|
|
|
Group: Members Posts: 129 Joined: 29-May 04 Member No.: 3,485 |
|
|
|
|
Sep 27 2005, 10:25 PM
Post
#4
|
|
|
Group: Members Posts: 78 Joined: 28-January 04 From: clovis CA USA Member No.: 1,580 |
Bam - sorry for the delay in getting back to you with the source code. That is if you are still interested in capturing a event from inside your QT/Qtopia program/
channel = new QCopChannel( "QPE/Card", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(mediaAlert(const QCString&, const QByteArray&)) ); Hope the above signal/slot work, its been a while and I had it commented out in my code but recall it working at one time. The hard part I had was in figuring out what media device was loaded/unloaded. I did something crude like: (sorry for this hack, but hope it gets the point home) /**********************************************************/ void AllTracker::mediaAlert(const QCString & cstr, const QByteArray& ba) { bool mounted; int status; QByteArray cs; QCString cs1; QDir workDir("/mnt/card"); qDebug("MEDIA ALERT..."); mediaNotice = new QMessageBox(tr("Media ALERT"), cstr, QMessageBox::Warning , QMessageBox: this,0,TRUE); mediaNotice->exec(); delete mediaNotice; if (cstr.contains("mtabChanged") != TRUE) return; // For some reason I could not do a read on /proc/mount so // had to cat it to a normal file then read it system("cat /proc/mounts > /tmp/mounts"); QFile mntFile("/tmp/mounts"); if (mntFile.exists() != TRUE) { qWarning("Can't find /proc/mounts"); return; } status = mntFile.open(IO_ReadOnly ); if (status != TRUE) { qWarning("Can't open /tmp/mounts"); return; } cs = mntFile.readAll(); if (cs.size() < 1) { qWarning("No data in /tmp/mounts"); return; } cs1 = cs; if (cs1.contains("card")) { qDebug("Found mnt"); mounted = TRUE; } else { qDebug("Media Not found"); mounted = FALSE; } if (mounted == FALSE) { if (run == 0) return; qDebug("work dir == 0"); mediaNotice = new QMessageBox(tr("Media Removal Warning"), tr("Save transactions before\nremoving media"), QMessageBox::Warning , QMessageBox: this,0,TRUE); mediaNotice->exec(); delete mediaNotice; mediaNotice = 0; } else { // is mounted QApplication::beep(); if (run == 0) { loadData(); return; } if (turnOffMedia != TRUE) { mediaNotice = new QMessageBox(tr("Medial Alert"), tr("Reload Data from Media"), QMessageBox::Information , QMessageBox::Yes, QMessageBox::No,0, this,0,TRUE); status = mediaNotice->exec(); delete mediaNotice; mediaNotice = 0; qDebug("status =f media dialog = %d",status); turnOffMedia = FALSE; } } } QUOTE(boosalis @ Sep 23 2005, 10:47 AM)
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 19th June 2013 - 05:26 PM |