00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <qapplication.h>
00010
00011 #include <stdlib.h>
00012 #include <unistd.h>
00013 #include <iostream>
00014 using namespace std;
00015
00016 #include <mythtv/mythcontext.h>
00017 #include <mythtv/mythmediamonitor.h>
00018 #include <mythtv/uitypes.h>
00019 #include <mythtv/compat.h>
00020
00021 #include "dvdripbox.h"
00022 #include "titledialog.h"
00023
00024 MTDJob::MTDJob()
00025 :QObject(NULL)
00026 {
00027 init();
00028 }
00029
00030 MTDJob::MTDJob(const QString &a_name)
00031 {
00032 init();
00033 job_name = a_name;
00034 }
00035
00036 void MTDJob::init()
00037 {
00038 job_number = -1;
00039 job_name = "";
00040 current_activity = "";
00041 overall_progress = 0.0;
00042 subjob_progress = 0.0;
00043 cancelled = false;
00044 }
00045
00046 void MTDJob::SetName(const QString &a_name)
00047 {
00048 if(a_name != job_name && cancelled)
00049 {
00050 cancelled = false;
00051 emit toggledCancelled();
00052 }
00053 job_name = a_name;
00054 }
00055
00056 void MTDJob::setActivity(const QString &an_act)
00057 {
00058 if(!cancelled)
00059 {
00060 current_activity = an_act;
00061 }
00062 }
00063
00064 void MTDJob::setSubjob(double a_number)
00065 {
00066 if(!cancelled)
00067 {
00068 subjob_progress = a_number;
00069 }
00070 }
00071
00072
00073
00074
00075
00076
00077 DVDRipBox::DVDRipBox(MythMainWindow *parent, QString window_name,
00078 QString device, QString theme_filename, const char *name)
00079
00080 : MythThemedDialog(parent, window_name, theme_filename, name)
00081 {
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 client_socket = NULL;
00101 tried_mtd = false;
00102 connected = false;
00103 jobs.clear();
00104 jobs.setAutoDelete(true);
00105 numb_jobs = 0;
00106 current_job = -1;
00107 first_time_through = true;
00108 have_disc = false;
00109 first_disc_found = false;
00110 block_media_requests = false;
00111 ignore_cancels = false;
00112 m_device = device;
00113
00114
00115
00116
00117
00118
00119 status_timer = new QTimer(this);
00120 connect(status_timer, SIGNAL(timeout()), this, SLOT(pollStatus()));
00121
00122
00123
00124
00125
00126
00127
00128 wireUpTheme();
00129 assignFirstFocus();
00130
00131
00132
00133
00134
00135 setContext(0);
00136 createSocket();
00137 connectToMtd(false);
00138
00139
00140
00141
00142
00143
00144
00145 QString dvd_device = MediaMonitor::defaultDVDdevice();
00146 dvd_info = NULL;
00147 disc_checking_timer = new QTimer();
00148 disc_checking_timer->start(600);
00149 connect(disc_checking_timer, SIGNAL(timeout()), this, SLOT(checkDisc()));
00150 }
00151
00152 void DVDRipBox::checkDisc()
00153 {
00154 if(!connected)
00155 {
00156 return;
00157 }
00158
00159 if(block_media_requests)
00160 {
00161 return;
00162 }
00163
00164 if(have_disc)
00165 {
00166 if(ripscreen_button)
00167 {
00168 if(ripscreen_button->GetContext() != -1)
00169 {
00170 ripscreen_button->allowFocus(true);
00171 ripscreen_button->SetContext(-1);
00172 ripscreen_button->refresh();
00173 }
00174 }
00175 if(!first_disc_found)
00176 {
00177 first_disc_found = true;
00178
00179
00180
00181
00182
00183
00184 disc_checking_timer->changeInterval(4000);
00185 }
00186
00187 }
00188 else
00189 {
00190 if(ripscreen_button)
00191 {
00192 if(ripscreen_button->GetContext() != -2)
00193 {
00194 ripscreen_button->allowFocus(false);
00195 ripscreen_button->SetContext(-2);
00196 ripscreen_button->refresh();
00197 }
00198 }
00199 }
00200
00201
00202
00203
00204
00205 sendToServer("media");
00206 }
00207
00208 void DVDRipBox::createSocket()
00209 {
00210 if(client_socket)
00211 {
00212 delete client_socket;
00213 }
00214 client_socket = new QSocket(this);
00215 connect(client_socket, SIGNAL(error(int)), this, SLOT(connectionError(int)));
00216 connect(client_socket, SIGNAL(connected()), this, SLOT(connectionMade()));
00217 connect(client_socket, SIGNAL(readyRead()), this, SLOT(readFromServer()));
00218 connect(client_socket, SIGNAL(connectionClosed()), this, SLOT(connectionClosed()));
00219 }
00220
00221 void DVDRipBox::connectionClosed()
00222 {
00223 if(client_socket)
00224 {
00225 delete client_socket;
00226 client_socket = NULL;
00227 connected = false;
00228 }
00229
00230 stopStatusPolling();
00231 setContext(0);
00232 have_disc = false;
00233 if(ripscreen_button)
00234 {
00235 ripscreen_button->allowFocus(false);
00236 ripscreen_button->SetContext(-2);
00237 ripscreen_button->refresh();
00238 }
00239 if(cancel_button)
00240 {
00241 cancel_button->allowFocus(false);
00242 cancel_button->SetContext(-2);
00243 cancel_button->refresh();
00244 }
00245 QString warning = tr("Your connection to the Myth "
00246 "Transcoding Daemon has gone "
00247 "away. This is not a good thing.");
00248 warning_text->SetText(warning);
00249 update();
00250 }
00251
00252 void DVDRipBox::connectToMtd(bool try_to_run_mtd)
00253 {
00254 if(try_to_run_mtd && !tried_mtd)
00255 {
00256
00257
00258
00259 system(QString("%1/bin/mtd -d").arg(gContext->GetInstallPrefix()));
00260
00261
00262
00263
00264
00265 usleep(200000);
00266 tried_mtd = true;
00267 }
00268
00269 int a_port = gContext->GetNumSetting("MTDPort", 2442);
00270 if(a_port > 0 && a_port < 65536)
00271 {
00272 client_socket->connectToHost("localhost", a_port);
00273 }
00274 else
00275 {
00276 cerr << "dvdripbox.o: Can't get a reasonable port number" << endl;
00277 exit(0);
00278 }
00279 }
00280
00281 void DVDRipBox::keyPressEvent(QKeyEvent *e)
00282 {
00283 bool handled = false;
00284 QStringList actions;
00285 gContext->GetMainWindow()->TranslateKeyPress("DVD", e, actions);
00286
00287 for (unsigned int i = 0; i < actions.size() && !handled; i++)
00288 {
00289 QString action = actions[i];
00290 handled = true;
00291 if (action == "UP")
00292 nextPrevWidgetFocus(false);
00293 else if (action == "DOWN")
00294 nextPrevWidgetFocus(true);
00295 else if (action == "SELECT")
00296 activateCurrent();
00297 else
00298 handled = false;
00299
00300 if (getContext() == 1)
00301 {
00302 if (action == "0" || action == "1" || action == "2" ||
00303 action == "3" || action == "4" || action == "5" ||
00304 action == "6" || action == "7" || action == "8" ||
00305 action == "9")
00306 {
00307 connectToMtd(true);
00308 }
00309 else
00310 handled = false;
00311 }
00312 else if (getContext() == 2 && have_disc)
00313 {
00314 if (action == "0")
00315 {
00316 if (ripscreen_button && ripscreen_button->GetContext() == -1)
00317 ripscreen_button->push();
00318 }
00319 else
00320 handled = false;
00321 }
00322 else if (getContext() == 3)
00323 {
00324 if (action == "RIGHT")
00325 {
00326 if (nextjob_button)
00327 nextjob_button->push();
00328 }
00329 else if (action == "LEFT")
00330 {
00331 if (prevjob_button)
00332 prevjob_button->push();
00333 }
00334 else if (action == "0")
00335 {
00336 if (ripscreen_button && ripscreen_button->GetContext() != -2)
00337 ripscreen_button->push();
00338 }
00339 else if (action == "9")
00340 {
00341 if (cancel_button)
00342 cancel_button->push();
00343 }
00344 else if (action == "1" || action == "2" || action == "3" ||
00345 action == "4" || action == "5" || action == "6" ||
00346 action == "7" || action == "8")
00347 {
00348 goToJob(action.toInt());
00349 }
00350 else
00351 handled = false;
00352 }
00353 else
00354 handled = false;
00355 }
00356
00357 if (!handled)
00358 MythThemedDialog::keyPressEvent(e);
00359 }
00360
00361 void DVDRipBox::nextJob()
00362 {
00363 if(current_job + 1 < (int) numb_jobs)
00364 {
00365 current_job++;
00366 }
00367 showCurrentJob();
00368 }
00369
00370
00371 void DVDRipBox::prevJob()
00372 {
00373 if(current_job > 0)
00374 {
00375 current_job--;
00376 }
00377 showCurrentJob();
00378 }
00379
00380 void DVDRipBox::goToJob(int which_job)
00381 {
00382 which_job--;
00383 if(which_job > -1 &&
00384 which_job < (int) numb_jobs)
00385 {
00386 current_job = which_job;
00387 showCurrentJob();
00388 }
00389 }
00390
00391
00392 void DVDRipBox::connectionError(int error_id)
00393 {
00394
00395
00396
00397
00398
00399 createSocket();
00400 setContext(1);
00401
00402
00403
00404 if(error_id == QSocket::ErrConnectionRefused)
00405 {
00406 QString warning = tr("Cannot connect to your Myth "
00407 "Transcoding Daemon. You can try "
00408 "hitting any number key to start "
00409 "it. If you still see this message, "
00410 "then something is really wrong.");
00411 warning_text->SetText(warning);
00412 }
00413 else if(error_id == QSocket::ErrHostNotFound)
00414 {
00415 QString warning = tr("Attempting to connect to your "
00416 "mtd said host not found. This "
00417 "is unrecoverably bad. ");
00418 warning_text->SetText(warning);
00419 }
00420 else if(error_id == QSocket::ErrSocketRead)
00421 {
00422 QString warning = tr("Socket communication errors. "
00423 "This is unrecoverably bad. ");
00424 warning_text->SetText(warning);
00425 }
00426 else
00427 {
00428 QString warning = tr("Something is wrong, but I don't "
00429 "know what.");
00430 warning_text->SetText(warning);
00431
00432 }
00433 }
00434
00435 void DVDRipBox::connectionMade()
00436 {
00437
00438
00439
00440
00441 setContext(2);
00442 connected = true;
00443 sendToServer("hello");
00444 sendToServer("use dvd " + m_device);
00445 }
00446
00447 void DVDRipBox::readFromServer()
00448 {
00449 while(client_socket->canReadLine())
00450 {
00451 QString line_from_server = QString::fromUtf8(client_socket->readLine());
00452 line_from_server = line_from_server.replace( QRegExp("\n"), "" );
00453 line_from_server = line_from_server.replace( QRegExp("\r"), "" );
00454 line_from_server.simplifyWhiteSpace();
00455
00456 QStringList tokens = QStringList::split(" ", line_from_server);
00457 if(tokens.count() > 0)
00458 {
00459 parseTokens(tokens);
00460 }
00461 }
00462 }
00463
00464 void DVDRipBox::sendToServer(const QString &some_text)
00465 {
00466 if(connected)
00467 {
00468 QTextStream os(client_socket);
00469 os << some_text << "\n";
00470 }
00471 else
00472 {
00473 cerr << "dvdripbox.o: was asked to send the following text while not connected: \""
00474 << some_text
00475 << "\""
00476 << endl;
00477 }
00478 }
00479
00480 void DVDRipBox::parseTokens(QStringList tokens)
00481 {
00482 if(tokens[0] == "greetings")
00483 {
00484 startStatusPolling();
00485 }
00486 if(tokens[0] == "status")
00487 {
00488 handleStatus(tokens);
00489 }
00490 if(tokens[0] == "media")
00491 {
00492 handleMedia(tokens);
00493 }
00494 }
00495
00496 void DVDRipBox::startStatusPolling()
00497 {
00498 status_timer->start(1000);
00499 }
00500
00501 void DVDRipBox::stopStatusPolling()
00502 {
00503 status_timer->stop();
00504 }
00505
00506 void DVDRipBox::pollStatus()
00507 {
00508
00509
00510
00511
00512 sendToServer("status");
00513
00514 }
00515
00516 void DVDRipBox::showCurrentJob()
00517 {
00518 if(current_job > -1)
00519 {
00520 MTDJob *a_job = jobs.at((uint)current_job);
00521 if(overall_text)
00522 {
00523 overall_text->SetText(a_job->getName());
00524 }
00525 if(job_text)
00526 {
00527 job_text->SetText(a_job->getActivity());
00528 }
00529 if(overall_status)
00530 {
00531 int an_int = (int) (a_job->getOverall() * 1000);
00532 overall_status->SetUsed(an_int);
00533 }
00534 if(job_status)
00535 {
00536 int an_int = (int) (a_job->getSubjob() * 1000);
00537 job_status->SetUsed(an_int);
00538 }
00539 if(numb_jobs_text)
00540 {
00541 numb_jobs_text->SetText(QString(tr("Job %1 of %2")).arg(current_job + 1).arg(numb_jobs));
00542 }
00543 }
00544 else
00545 {
00547 }
00548 }
00549
00550 void DVDRipBox::handleStatus(QStringList tokens)
00551 {
00552
00553
00554
00555
00556 if(tokens.count() < 3)
00557 {
00558 cerr << "dvdripbox.o: I got an mtd status update with a bad number of tokens" << endl;
00559 return;
00560 }
00561
00562 if(tokens[1] != "dvd")
00563 {
00564
00565
00566
00567
00568 return;
00569
00570 }
00571
00572 if(tokens[2] == "complete")
00573 {
00574
00575
00576
00577 showCurrentJob();
00578 return;
00579 }
00580
00581 if(tokens.count() < 4)
00582 {
00583 cerr << "dvdripbox.o: I got an mtd update I couldn't understand:" << tokens.join(" ") << endl;
00584 return;
00585 }
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 if(getContext() < 3)
00598 {
00599 if((tokens[2] == "summary" &&
00600 tokens[3].toInt() > 0) ||
00601 (tokens[2] == "job"))
00602 {
00603
00604 cancel_button->SetContext(3);
00605 cancel_button->allowFocus(true);
00606 setContext(3);
00607 update();
00608 if(warning_text)
00609 {
00610 warning_text->SetText("");
00611 }
00612 }
00613 else
00614 {
00615 setContext(2);
00616 update();
00617 if(have_disc)
00618 {
00619 if(first_time_through)
00620 {
00621 first_time_through = false;
00622 goRipScreen();
00623 }
00624 else
00625 {
00626 if(warning_text)
00627 {
00628 warning_text->SetText(tr("No jobs and nothing else to do. You could rip a DVD."));
00629 }
00630 }
00631 }
00632 else
00633 {
00634 if(warning_text)
00635 {
00636 warning_text->SetText(tr("No Jobs. Checking and/or waiting for DVD."));
00637 }
00638 }
00639 }
00640 }
00641 else if(getContext() == 3)
00642 {
00643 if(tokens[2] == "summary" && tokens[3].toInt() == 0)
00644 {
00645 setContext(2);
00646 update();
00647 if(have_disc)
00648 {
00649 if(warning_text)
00650 {
00651 warning_text->SetText(tr("No jobs and nothing else to do. You could rip a disc if you like."));
00652 }
00653 }
00654 else
00655 {
00656 if(warning_text)
00657 {
00658 warning_text->SetText(tr("No Jobs. Checking and/or waiting for DVD."));
00659 }
00660 }
00661
00662 }
00663 }
00664
00665
00666
00667
00668
00669
00670 if(tokens[2] == "summary")
00671 {
00672
00673
00674
00675
00676
00677 if(tokens[3].toUInt() != numb_jobs)
00678 {
00679 adjustJobs(tokens[3].toUInt());
00680 }
00681 return;
00682
00683 }
00684
00685
00686
00687
00688
00689
00690 if(tokens.count() < 6)
00691 {
00692 cerr << "dvdripbox.o: got wrong number of tokens on a DVD job." << endl;
00693 return;
00694 }
00695 else if(tokens[2] == "job" && tokens[4] == "overall")
00696 {
00697 QString title = "";
00698 for(uint i = 6; i < tokens.count(); i++)
00699 {
00700 title.append(tokens[i]);
00701 if(i != tokens.count() - 1)
00702 {
00703 title.append(" ");
00704 }
00705 }
00706 setOverallJobStatus(tokens[3].toInt(), tokens[5].toDouble(), title);
00707 }
00708 else if(tokens[2] == "job" && tokens[4] == "subjob")
00709 {
00710 QString subjob_string = "";
00711 for(uint i = 6; i < tokens.count(); i++)
00712 {
00713 subjob_string.append(tokens[i]);
00714 if(i != tokens.count() - 1)
00715 {
00716 subjob_string.append(" ");
00717 }
00718 }
00719 setSubJobStatus(tokens[3].toInt(), tokens[5].toDouble(), subjob_string);
00720 }
00721 else
00722 {
00723 cerr << "dvdripbox.o: Getting stuff I don't understand from the mtd" << endl ;
00724 }
00725
00726 }
00727
00728 void DVDRipBox::handleMedia(QStringList tokens)
00729 {
00730
00731
00732
00733
00734 if(tokens.count() < 3)
00735 {
00736 cerr << "dvdripbox.o: I got an mtd media update with a bad number of tokens" << endl;
00737 return;
00738 }
00739
00740 if(tokens[1] != "dvd")
00741 {
00742
00743
00744
00745
00746 return;
00747
00748 }
00749
00750
00751 if(tokens[2] == "complete")
00752 {
00753 block_media_requests = false;
00754 if(dvd_info)
00755 {
00756 if(dvd_info->getTitles()->count() > 0)
00757 {
00758 have_disc = true;
00759 if(ripscreen_button)
00760 {
00761 if(ripscreen_button->GetContext() != -1)
00762 {
00763 ripscreen_button->allowFocus(true);
00764 }
00765 }
00766 }
00767 else
00768 {
00769 have_disc = false;
00770 if(ripscreen_button)
00771 {
00772 if(ripscreen_button->GetContext() != -2)
00773 {
00774 ripscreen_button->allowFocus(false);
00775 ripscreen_button->SetContext(-1);
00776 ripscreen_button->refresh();
00777 }
00778 }
00779 }
00780 }
00781 return;
00782 }
00783 else if(tokens[2] == "summary")
00784 {
00785 block_media_requests = true;
00786 if(dvd_info)
00787 {
00788 delete dvd_info;
00789 dvd_info = NULL;
00790 }
00791 if(tokens[3].toUInt() > 0)
00792 {
00793 QString disc_name = "";
00794 for(uint i = 4; i < tokens.count(); i++)
00795 {
00796 disc_name += tokens[i];
00797 if(i < tokens.count() - 1)
00798 {
00799 disc_name += " ";
00800 }
00801 }
00802 dvd_info = new DVDInfo(disc_name);
00803 }
00804 else
00805 {
00806 have_disc = false;
00807 if(ripscreen_button)
00808 {
00809 if(ripscreen_button->GetContext() != -2)
00810 {
00811 ripscreen_button->allowFocus(false);
00812 ripscreen_button->SetContext(-2);
00813 ripscreen_button->refresh();
00814 }
00815 }
00816 }
00817 return;
00818 }
00819 else if(tokens[2] == "title")
00820 {
00821 if(tokens.count() != 10)
00822 {
00823 cerr << "dvdripbox.o: Got wrong number of tokens in media title report." << endl;
00824 return;
00825 }
00826 else
00827 {
00828 DVDTitleInfo *new_title = new DVDTitleInfo();
00829 new_title->setTrack(tokens[3].toUInt());
00830 new_title->setChapters(tokens[4].toUInt());
00831 new_title->setAngles(tokens[5].toUInt());
00832 new_title->setTime(tokens[6].toUInt(), tokens[7].toUInt(), tokens[8].toUInt());
00833 new_title->setInputID(tokens[9].toUInt());
00834 dvd_info->addTitle(new_title);
00835 }
00836 return;
00837 }
00838 else if(tokens[2] == "title-audio")
00839 {
00840 DVDTitleInfo *which_title = dvd_info->getTitle(tokens[3].toUInt());
00841 if(!which_title)
00842 {
00843 cerr << "dvdripbox.o: Asked to add an audio track for a title that doesn't exist" << endl;
00844 return;
00845 }
00846
00847 QString audio_string = "";
00848 for(uint i = 6; i < tokens.count(); i++)
00849 {
00850 audio_string += tokens[i];
00851 if(i < tokens.count() - 1)
00852 {
00853 audio_string += " ";
00854 }
00855 }
00856
00857 DVDAudioInfo *new_audio = new DVDAudioInfo(tokens[4].toUInt() + 1, audio_string);
00858 new_audio->setChannels(tokens[5].toInt());
00859 which_title->addAudio(new_audio);
00860 }
00861 else if(tokens[2] == "title-subtitle")
00862 {
00863 DVDTitleInfo *which_title = dvd_info->getTitle(tokens[3].toUInt());
00864 if(!which_title)
00865 {
00866 cerr << "dvdripbox.o: Asked to add a subtitle for a title that doesn't exist" << endl;
00867 return;
00868 }
00869
00870 QString name_string = "";
00871 for(uint i = 6; i < tokens.count(); i++)
00872 {
00873 name_string += tokens[i];
00874 if(i < tokens.count() - 1)
00875 {
00876 name_string += " ";
00877 }
00878 }
00879 DVDSubTitleInfo *new_subtitle = new DVDSubTitleInfo(tokens[4].toInt(), name_string);
00880 which_title->addSubTitle(new_subtitle);
00881 }
00882
00883 }
00884
00885
00886
00887 void DVDRipBox::setOverallJobStatus(int job_number, double status, QString title)
00888 {
00889 if(job_number + 1 > (int) jobs.count())
00890 {
00891 cerr << "dvdripbox.o: mtd job summary didn't tell us the right number of jobs" << endl;
00892 cerr << " (int) jobs.count() is " << (int) jobs.count() << endl;
00893 cerr << " requested job_number was " << job_number << endl ;
00894 }
00895 else
00896 {
00897 MTDJob *which_one = jobs.at(job_number);
00898 which_one->SetName(title);
00899 which_one->setOverall(status);
00900 which_one->setNumber(job_number);
00901 }
00902 }
00903
00904 void DVDRipBox::setSubJobStatus(int job_number, double status, QString subjob_string)
00905 {
00906 if(job_number + 1 > (int) jobs.count())
00907 {
00908 cerr << "dvdripbox.o: mtd job summary didn't tell us the right number of jobs. The Bastard!" << endl;
00909 }
00910 else
00911 {
00912 MTDJob *which_one = jobs.at(job_number);
00913 which_one->setActivity(subjob_string);
00914 which_one->setSubjob(status);
00915 }
00916 }
00917
00918 void DVDRipBox::adjustJobs(uint new_number)
00919 {
00920 if(new_number > numb_jobs)
00921 {
00922 for(uint i = 0; i < (new_number - numb_jobs); i++)
00923 {
00924 MTDJob *new_one = new MTDJob("I am a job");
00925 connect(new_one, SIGNAL(toggledCancelled()), this, SLOT(toggleCancel()));
00926 jobs.append(new_one);
00927 }
00928 if(current_job < 0)
00929 {
00930 current_job = 0;
00931 }
00932 }
00933 else if(new_number < numb_jobs)
00934 {
00935 for(uint i = 0; i < (numb_jobs - new_number); i++)
00936 {
00937 jobs.remove(jobs.getLast());
00938 }
00939 if(current_job >= (int) jobs.count())
00940 {
00941 current_job = jobs.count() - 1;
00942 }
00943 }
00944 numb_jobs = new_number;
00945 if(numb_jobs == 0)
00946 {
00947 if(ignore_cancels)
00948 {
00949 toggleCancel();
00950 }
00951 }
00952 }
00953
00954 void DVDRipBox::goRipScreen()
00955 {
00956 if(warning_text)
00957 {
00958 warning_text->SetText("");
00959 }
00960 stopStatusPolling();
00961 block_media_requests = true;
00962 TitleDialog title_dialog(client_socket,
00963 dvd_info->getName(),
00964 dvd_info->getTitles(),
00965 gContext->GetMainWindow(),
00966 "title_dialog",
00967 "dvd-",
00968 "title dialog");
00969 title_dialog.exec();
00970 block_media_requests = false;
00971 pollStatus();
00972 showCurrentJob();
00973 warning_text->SetText("");
00974
00975 startStatusPolling();
00976 }
00977
00978 void DVDRipBox::cancelJob()
00979 {
00980 if( current_job > -1 &&
00981 current_job < (int) jobs.count() &&
00982 !ignore_cancels)
00983 {
00984 if(jobs.at(current_job)->getNumber() >= 0)
00985 {
00986 ignore_cancels = true;
00987 stopStatusPolling();
00988 sendToServer(QString("abort dvd job %1").arg(jobs.at(current_job)->getNumber()));
00989 qApp->processEvents();
00990 jobs.at(current_job)->setSubjob(0.0);
00991 jobs.at(current_job)->setActivity(tr("Cancelling ..."));
00992 jobs.at(current_job)->setCancelled(true);
00993 showCurrentJob();
00994 startStatusPolling();
00995 }
00996 }
00997 }
00998
00999 void DVDRipBox::toggleCancel()
01000 {
01001 ignore_cancels = false;
01002 }
01003
01004 void DVDRipBox::wireUpTheme()
01005 {
01006 warning_text = getUITextType("warning");
01007 if(!warning_text)
01008 {
01009 cerr << "dvdripbox.o: Couldn't find a text type called warning in your theme" << endl;
01010 exit(0);
01011 }
01012
01013 overall_text = getUITextType("overall_text");
01014 job_text = getUITextType("job_text");
01015 numb_jobs_text = getUITextType("numb_jobs_text");
01016 nodvd_text = getUITextType("nodvd_text");
01017 overall_status = getUIStatusBarType("overall_status");
01018 if(overall_status)
01019 {
01020 overall_status->SetTotal(1000);
01021 overall_status->SetUsed(0);
01022 }
01023 job_status = getUIStatusBarType("job_status");
01024 if(job_status)
01025 {
01026 job_status->SetTotal(1000);
01027 job_status->SetUsed(0);
01028 }
01029
01030 nextjob_button = getUIPushButtonType("job_next_button");
01031 if(nextjob_button)
01032 {
01033 connect(nextjob_button, SIGNAL(pushed()), this, SLOT(nextJob()));
01034 }
01035 prevjob_button = getUIPushButtonType("job_prev_button");
01036 if(prevjob_button)
01037 {
01038 connect(prevjob_button, SIGNAL(pushed()), this, SLOT(prevJob()));
01039 }
01040
01041 ripscreen_button = getUITextButtonType("ripscreen_button");
01042 if(ripscreen_button)
01043 {
01044 ripscreen_button->setText(tr("New Rip"));
01045 connect(ripscreen_button, SIGNAL(pushed()), this, SLOT(goRipScreen()));
01046 ripscreen_button->SetContext(-2);
01047 }
01048
01049 cancel_button = getUITextButtonType("cancel_button");
01050 if(cancel_button)
01051 {
01052 cancel_button->setText(tr("Cancel Job"));
01053 connect(cancel_button, SIGNAL(pushed()), this, SLOT(cancelJob()));
01054 cancel_button->SetContext(-2);
01055 }
01056
01057 buildFocusList();
01058 }
01059
01060 DVDRipBox::~DVDRipBox(void)
01061 {
01062 if(client_socket)
01063 {
01064 client_socket->close();
01065 delete client_socket;
01066 }
01067 jobs.clear();
01068 }
01069