72 iGetDRMClockAct->setStatusTip(tr("Get DRM secure clock time.")); |
75 iGetDRMClockAct->setStatusTip(tr("Get DRM secure clock time.")); |
73 |
76 |
74 iEncryptAct = new QAction(tr("&Encrypt"), this); |
77 iEncryptAct = new QAction(tr("&Encrypt"), this); |
75 iEncryptAct->setStatusTip(tr("Encrypt")); |
78 iEncryptAct->setStatusTip(tr("Encrypt")); |
76 |
79 |
|
80 iLaunchBrowserAct = new QAction(tr("&Launch Browser"), this); |
|
81 iLaunchBrowserAct->setStatusTip(tr("Launch Browser")); |
|
82 |
77 iDeleteWMDRMDBAct = new QAction(tr("&Delete WMDRM DB"), this); |
83 iDeleteWMDRMDBAct = new QAction(tr("&Delete WMDRM DB"), this); |
78 iDeleteWMDRMDBAct->setStatusTip(tr("Delete WMDRM Database rights.")); |
84 iDeleteWMDRMDBAct->setStatusTip(tr("Delete WMDRM Database rights.")); |
79 |
85 |
80 menuBar()->addAction(iSetDRMClockAct); |
86 menuBar()->addAction(iSetDRMClockAct); |
81 menuBar()->addAction(iGetDRMClockAct); |
87 menuBar()->addAction(iGetDRMClockAct); |
82 menuBar()->addAction(iEncryptAct); |
88 menuBar()->addAction(iEncryptAct); |
83 menuBar()->addAction(iDeleteWMDRMDBAct); |
89 menuBar()->addAction(iDeleteWMDRMDBAct); |
|
90 menuBar()->addAction(iLaunchBrowserAct); |
84 |
91 |
85 connect(iSetDRMClockAct, SIGNAL(triggered()), this, SLOT(setDRMClock())); |
92 connect(iSetDRMClockAct, SIGNAL(triggered()), this, SLOT(setDRMClock())); |
86 connect(iGetDRMClockAct, SIGNAL(triggered()), this, SLOT(getDRMClock())); |
93 connect(iGetDRMClockAct, SIGNAL(triggered()), this, SLOT(getDRMClock())); |
87 connect(iEncryptAct, SIGNAL(triggered()), this, SLOT(startEncrypt())); |
94 connect(iEncryptAct, SIGNAL(triggered()), this, SLOT(startEncrypt())); |
88 connect(iDeleteWMDRMDBAct, SIGNAL(triggered()), this, SLOT(deleteWmDrmDB())); |
95 connect(iDeleteWMDRMDBAct, SIGNAL(triggered()), this, SLOT(deleteWmDrmDB())); |
|
96 connect(iLaunchBrowserAct, SIGNAL(triggered()), this, SLOT(launchBrowser())); |
89 |
97 |
90 //setDRMClockButton = new QPushButton("Set DRM Clock", this); |
98 //setDRMClockButton = new QPushButton("Set DRM Clock", this); |
91 //connect(setDRMClockButton, SIGNAL(clicked()), this, SLOT(setDRMClock())); |
99 //connect(setDRMClockButton, SIGNAL(clicked()), this, SLOT(setDRMClock())); |
92 //setDRMClockButton->show(); |
100 //setDRMClockButton->show(); |
93 |
101 |
114 dateTimeDialog->show(); |
122 dateTimeDialog->show(); |
115 } |
123 } |
116 |
124 |
117 void DRMEncryptor::getDRMClock() |
125 void DRMEncryptor::getDRMClock() |
118 { |
126 { |
119 TTime time; |
127 TTime time; |
120 TInt timeZone; |
128 TInt timeZone; |
121 TDateTime date; |
129 TDateTime date; |
122 DRMClock::ESecurityLevel level; |
130 DRMClock::ESecurityLevel level; |
123 TInt error( KErrNone ); |
131 TInt error( KErrNone ); |
124 TBuf< 80 > buf; |
132 TBuf< 80 > buf; |
125 |
133 |
126 DRM::CDrmServiceApi* service = DRM::CDrmServiceApi::NewLC(); |
134 DRM::CDrmServiceApi* service = NULL; |
|
135 |
|
136 TRAPD(err, service = DRM::CDrmServiceApi::NewL()); |
|
137 if(err!=KErrNone) |
|
138 { |
|
139 QMessageBox::information(this, tr("DRM Clock"),tr("Error creating CDrmServiceApi.")); |
|
140 buf.AppendNum(error); |
|
141 QString string((QChar*)buf.Ptr(),buf.Length()); |
|
142 QMessageBox::information(this, tr("DRM Clock"),string); |
|
143 delete service; // service |
|
144 return; |
|
145 } |
|
146 |
127 error = service->GetSecureTime( time, timeZone, level ); |
147 error = service->GetSecureTime( time, timeZone, level ); |
128 |
148 if(!error==KErrNone) |
129 CleanupStack::PopAndDestroy(); // service |
149 { |
|
150 QMessageBox::information(this, tr("DRM Clock"),tr("Error getting secure time.")); |
|
151 |
|
152 buf.AppendNum(error); |
|
153 QString string((QChar*)buf.Ptr(),buf.Length()); |
|
154 QMessageBox::information(this, tr("DRM Clock"),string); |
|
155 delete service; |
|
156 return; |
|
157 } |
130 |
158 |
131 date = time.DateTime(); |
159 date = time.DateTime(); |
132 |
160 |
133 if(level == DRMClock::KSecure) |
161 if(level == DRMClock::KSecure) |
134 { |
162 { |
161 QString datetimeString((QChar*)buf.Ptr(),buf.Length()); |
189 QString datetimeString((QChar*)buf.Ptr(),buf.Length()); |
162 |
190 |
163 QMessageBox *drmClockTime = new QMessageBox(this); |
191 QMessageBox *drmClockTime = new QMessageBox(this); |
164 drmClockTime->setWindowTitle(tr("DRM Clock")); |
192 drmClockTime->setWindowTitle(tr("DRM Clock")); |
165 drmClockTime->setText(datetimeString); |
193 drmClockTime->setText(datetimeString); |
166 |
|
167 |
194 |
168 layout->addWidget(drmClockTime); |
195 layout->addWidget(drmClockTime); |
169 drmClockTime->show(); |
196 drmClockTime->show(); |
170 |
197 |
171 } |
198 } |
579 else |
606 else |
580 { |
607 { |
581 QMessageBox::information(this, tr("WMDRM DB"),tr("Error deleting WMDRM rights.")); |
608 QMessageBox::information(this, tr("WMDRM DB"),tr("Error deleting WMDRM rights.")); |
582 } |
609 } |
583 } |
610 } |
|
611 |
|
612 void DRMEncryptor::launchBrowser() |
|
613 { |
|
614 /*_LIT( KTestDrmFile, "c:\\data\\others\\sd_water003.dcf" ); |
|
615 TInt urlLength = 256; |
|
616 TFileName fileName(KTestDrmFile); |
|
617 RFile file; |
|
618 RFs fs; |
|
619 |
|
620 User::LeaveIfError(fs.Connect()); |
|
621 TInt result = 0; |
|
622 |
|
623 result = file.Open(fs, fileName, EFileRead | EFileShareReadersOrWriters); |
|
624 |
|
625 CData* content = CData::NewLC( file, KDefaultContentObject, EPeek ); |
|
626 |
|
627 HBufC* rightsIssuerBuf = HBufC::NewLC( urlLength ); // Content issuer max URL length |
|
628 TPtr rightsIssuer(const_cast<TUint16*>(rightsIssuerBuf->Ptr()), 0, urlLength); |
|
629 |
|
630 // Get value of rights-issuer header field |
|
631 TInt error = content->GetStringAttribute( ERightsIssuerUrl, rightsIssuer ); |
|
632 rightsIssuer.TrimAll(); |
|
633 |
|
634 rightsIssuer.Insert(0, _L("http://")); |
|
635 |
|
636 HBufC* finalUrl = rightsIssuer.AllocLC(); |
|
637 |
|
638 DRM::CDrmBrowserLauncher::LaunchUrlL(*finalUrl); |
|
639 |
|
640 CleanupStack::PopAndDestroy(3); // finalUrl, rightsIssuerBuf, content;*/ |
|
641 } |
|
642 |
584 /* |
643 /* |
585 void DRMEncryptorsetDRMClock() |
644 void DRMEncryptorsetDRMClock() |
586 { |
645 { |
587 |
646 |
588 double value1 = ui->lineEdit->text().toDouble(&bOK1); |
647 double value1 = ui->lineEdit->text().toDouble(&bOK1); |
644 |
703 |
645 //this->setLayout(iLayout); |
704 //this->setLayout(iLayout); |
646 okButton->show(); |
705 okButton->show(); |
647 cancelButton->show(); |
706 cancelButton->show(); |
648 this->show(); |
707 this->show(); |
649 this->raise(); |
|
650 } |
708 } |
651 |
709 |
652 DateTimeDialog::~DateTimeDialog() |
710 DateTimeDialog::~DateTimeDialog() |
653 { |
711 { |
654 |
712 |
655 } |
713 } |
656 |
714 |
657 void DateTimeDialog::setDRMClock() |
715 void DateTimeDialog::setDRMClock() |
658 { |
716 { |
659 DRM::CDrmServiceApi* service = DRM::CDrmServiceApi::NewLC(); |
717 DRM::CDrmServiceApi* service = NULL; |
|
718 TBuf<5> buf; |
|
719 TRAPD(err, service = DRM::CDrmServiceApi::NewL()); |
|
720 if(err!=KErrNone) |
|
721 { |
|
722 QMessageBox::information(this, tr("DRM Clock"),tr("Error creating CDrmServiceApi.")); |
|
723 buf.AppendNum(err); |
|
724 QString string((QChar*)buf.Ptr(),buf.Length()); |
|
725 QMessageBox::information(this, tr("DRM Clock"),string); |
|
726 delete service; // service |
|
727 return; |
|
728 } |
|
729 |
660 QString datetimeString = iDateEdit->dateTime().toString("yyyy.mm.dd hh.mm.ss"); |
730 QString datetimeString = iDateEdit->dateTime().toString("yyyy.mm.dd hh.mm.ss"); |
661 |
731 |
662 // datetime in format YYYYMMDD:HHMMSS for TTime |
732 // datetime in format YYYYMMDD:HHMMSS for TTime |
663 datetimeString.remove(QChar('.')); |
733 datetimeString.remove(QChar('.')); |
664 datetimeString.replace(" ", ":"); |
734 datetimeString.replace(" ", ":"); |
665 datetimeString.append(".000000"); |
735 datetimeString.append(".000000"); |
666 |
736 |
667 TPtrC datetimePtr(reinterpret_cast<const TText*>(datetimeString.constData())); |
737 TPtrC datetimePtr(reinterpret_cast<const TText*>(datetimeString.constData())); |
668 HBufC *datetimeBuf = datetimePtr.AllocLC(); |
738 HBufC *datetimeBuf = NULL; |
|
739 TBuf<5> errorBuf; |
|
740 TRAPD(errorCode, datetimeBuf = datetimePtr.AllocL()); |
|
741 if(errorCode!=KErrNone) |
|
742 { |
|
743 QMessageBox::information(this, tr("DRM Clock"),tr("Error in datetimePtr.AllocL.")); |
|
744 errorBuf.AppendNum(errorCode); |
|
745 QString string((QChar*)buf.Ptr(),buf.Length()); |
|
746 QMessageBox::information(this, tr("DRM Clock"),string); |
|
747 delete service; |
|
748 delete datetimeBuf; |
|
749 return; |
|
750 } |
|
751 |
669 |
752 |
670 TTime inputTime(*datetimeBuf); |
753 TTime inputTime(*datetimeBuf); |
671 TInt timezone = 0; |
754 TInt timezone = 0; |
|
755 delete datetimeBuf; |
672 |
756 |
673 // Get secure time from service api to get timezone |
757 // Get secure time from service api to get timezone |
674 DRMClock::ESecurityLevel level; |
758 DRMClock::ESecurityLevel level; |
675 TInt error( KErrNone ); |
759 TInt error( KErrNone ); |
676 |
760 |
687 if(error != KErrNone) |
771 if(error != KErrNone) |
688 { |
772 { |
689 return; |
773 return; |
690 } |
774 } |
691 |
775 |
692 CleanupStack::PopAndDestroy(2); // datetimeBuf, service |
776 delete service; |
|
777 |
693 QMessageBox::information(this, tr("DRM Clock"),tr("DRM Clock Set")); |
778 QMessageBox::information(this, tr("DRM Clock"),tr("DRM Clock Set")); |
694 |
779 } |
695 /* |
780 |
696 QGridLayout *layout = new QGridLayout; |
|
697 layout->setAlignment(Qt::AlignTop); |
|
698 QLabel *secureTimeSetComplete = new QLabel("DRM Clock Set"); |
|
699 layout->addWidget(secureTimeSetComplete); |
|
700 QPushButton *button = new QPushButton("Ok"); |
|
701 layout->addWidget(button); |
|
702 button->show(); |
|
703 secureTimeSetComplete->show(); |
|
704 connect(button, SIGNAL(clicked()), this, SLOT(close())); |
|
705 */ |
|
706 |
|
707 } |
|
708 |
|