42
42
#include "plugin_setup.h"
43
43
#include "plugin_types.h"
44
44
#include "plugin_dbus.h"
45
#include "nsIPrefBranch.h"
46
#include "nsIPrefService.h"
47
#include "nsIServiceManager.h"
49
nsIPrefBranch *prefBranch = NULL;
50
nsIPrefService *prefService = NULL;
46
51
static NPObject *sWindowObj;
48
53
//#include "nsIServiceManager.h"
180
void setPreference(CPlugin * instance, const gchar * name, const gchar * value)
182
nsIServiceManager *sm = NULL;
183
NPN_GetValue(NULL, NPNVserviceManager, &sm);
188
sm->GetServiceByContractID("@mozilla.org/preferences-service;1", NS_GET_IID(nsIPrefService), (void **)&prefService);
190
prefService->GetBranch("", &prefBranch);
192
instance->user_agent = g_new0(gchar, 1024);
193
prefBranch->PrefHasUserValue(name,&v);
195
prefBranch->GetCharPref(name, &(instance->user_agent));
196
prefBranch->SetCharPref(name, value);
204
void clearPreference(CPlugin * instance, const gchar * name)
206
nsIServiceManager *sm = NULL;
207
NPN_GetValue(NULL, NPNVserviceManager, &sm);
211
sm->GetServiceByContractID("@mozilla.org/preferences-service;1", NS_GET_IID(nsIPrefService), (void **)&prefService);
213
prefService->GetBranch("", &prefBranch);
215
if (instance->user_agent == NULL || strlen(instance->user_agent) == 0) {
216
prefBranch->ClearUserPref(name);
218
if (g_strrstr(instance->user_agent,"QuickTime/7.6.2")) {
219
prefBranch->ClearUserPref(name);
221
prefBranch->SetCharPref(name, instance->user_agent);
224
g_free(instance->user_agent);
175
231
////////////////////////////////////////
177
233
// CPlugin class implementation
555
614
ready = item->playerready;
556
615
newwindow = item->newwindow;
557
616
playlist = list_parse_qt(playlist, item);
617
playlist = list_parse_qt2(playlist, item);
558
618
playlist = list_parse_asx(playlist, item);
559
619
playlist = list_parse_qml(playlist, item);
560
620
playlist = list_parse_ram(playlist, item);
609
669
void CPlugin::URLNotify(const char *url, NPReason reason, void *notifyData)
611
671
ListItem *item = (ListItem *) notifyData;
612
DBusMessage *message;
672
//DBusMessage *message;
615
675
printf("URL Notify %s\n,%i = %i\n%s\n%s\n%s\n", url, reason, NPRES_DONE, item->src, item->local,
631
691
dbus_message_unref(message);
697
if (!item->streaming) {
698
item = list_find_next_playable(playlist);
700
if (item->retrieved) {
701
open_location(this, item, TRUE);
703
NPN_GetURLNotify(mInstance, item->src, NULL, item);
741
814
if (item->cancelled || item->retrieved)
742
815
NPN_DestroyStream(mInstance, stream, NPRES_USER_BREAK);
744
if (strstr((char *) buffer, "ICY 200 OK") != NULL || item->streaming == TRUE) {
745
item->streaming = TRUE;
746
open_location(this, item, FALSE);
747
item->requested = TRUE;
749
fclose(item->localfp);
751
NPN_DestroyStream(mInstance, stream, NPRES_DONE);
754
// If item is a block of jpeg images, just stream it
755
if (strstr((char *) buffer, "Content-length:") != NULL || item->streaming == TRUE) {
756
item->streaming = TRUE;
757
open_location(this, item, FALSE);
758
if (post_dom_events && this->id != NULL) {
759
postDOMEvent(mInstance, this->id, "qt_play");
761
item->requested = TRUE;
763
fclose(item->localfp);
765
NPN_DestroyStream(mInstance, stream, NPRES_DONE);
769
if (strstr((char *) buffer, "<HTML>") != NULL || item->streaming == TRUE) {
770
item->streaming = TRUE;
771
open_location(this, item, FALSE);
772
if (post_dom_events && this->id != NULL) {
773
postDOMEvent(mInstance, this->id, "qt_play");
775
item->requested = TRUE;
777
fclose(item->localfp);
779
NPN_DestroyStream(mInstance, stream, NPRES_DONE);
817
if (strstr((char *) buffer, "ICY 200 OK") != NULL
818
|| strstr((char *) buffer, "Content-length:") != NULL // If item is a block of jpeg images, just stream it
819
|| strstr((char *) buffer, "<HTML>") != NULL
820
|| item->streaming == TRUE
821
|| stream->lastmodified == 0) {
822
item->streaming = TRUE;
823
open_location(this, item, FALSE);
824
if (post_dom_events && this->id != NULL) {
825
postDOMEvent(mInstance, this->id, "qt_play");
827
item->requested = TRUE;
829
fclose(item->localfp);
831
NPN_DestroyStream(mInstance, stream, NPRES_USER_BREAK);