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:k,0,0,
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:k,0,0,
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;
}
}
}
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
[div align=\"right\"][a href=\"index.php?act=findpost&pid=96816\"][{POST_SNAPBACK}][/a][/div]