Permalink
Browse files

first commit

  • Loading branch information...
Paul Rouget
Paul Rouget committed Apr 22, 2011
0 parents commit 5e05e52f774cedf2432e3e13a5f014108e517d0b
Showing 590 changed files with 62,587 additions and 0 deletions.
@@ -0,0 +1,10 @@
+all:
+ gcc -g -O2 -pipe -Wall -pthread `pkg-config dbus-glib-1 --cflags` -c -o mediakeys.o mediakeys.c
+ gcc -o js/data/mediakeys.so mediakeys.o -pthread -shared `pkg-config dbus-glib-1 --libs` -fPIC
+ bash -c "cd js/sdk-1.0b4-modified/ && source bin/activate && cd .. && cfx xpi"
+ mv js/mediakeys.xpi .
+
+clean:
+ rm -f mediakeys.xpi
+ rm -f mediakeys.o
+ rm -f js/data/mediakeys.so
8 README
@@ -0,0 +1,8 @@
+Add "media" events support to Firefox.
+Works only on Linux (need help for Windows and Mac).
+
+Supports Mediakeys (play, pause, previous, next).
+Supports Media Events from the content ("sound", "nosound")
+and add a "playing" icon to the tab.
+
+See the GrooveShark Page Mode in js/lib/main.js for examples.
@@ -0,0 +1,2 @@
+gcc -g -O2 -pipe -Wall -pthread `pkg-config dbus-glib-1 --cflags` -c -o mediakeys.o mediakeys.c
+gcc -o mediakeys.so mediakeys.o -pthread -shared `pkg-config dbus-glib-1 --libs` -fPIC
No changes.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,118 @@
+const keys = ["unknownerror",
+ "mute",
+ "play",
+ "pause",
+ "stop",
+ "previous",
+ "next"];
+
+const URL = require("url");
+const data = require("self").data;
+const components = require("chrome").components;;
+const ctypes = components.utils.import("resource://gre/modules/ctypes.jsm").ctypes;
+const windows = require("windows");
+
+//
+// Send "media" events to all the web pages
+// We use jsctypes and a small C library
+//
+
+var cbType = ctypes.FunctionType(ctypes.default_abi, ctypes.void_t, [ctypes.int32_t]);
+var lib = ctypes.open(URL.toFilename(data.url("mediakeys.so")));
+var init = lib.declare("init", ctypes.default_abi, ctypes.void_t, cbType.ptr);
+
+function callback(key) {
+ for each (var window in windows.browserWindows) {
+ for each (var tab in window.tabs) {
+ var name = keys[key];
+ var evt = tab.contentDocument.createEvent("MessageEvent");
+ evt.initMessageEvent("media", true, true, name, tab.contentDocument.location.href, "", tab.contentWindow);
+ tab.contentDocument.dispatchEvent(evt);
+ }
+ }
+}
+
+var ptr = cbType.ptr(callback);
+init(ptr);
+
+
+//
+// listen to the "media" events from the web pages
+//
+
+let tracker = {
+ init: function() {
+ let windowTracker = new (require("window-utils").WindowTracker)(this);
+ },
+
+ onTrack: function(window) {
+ var document = window.document;
+ var style = document.createElementNS("http://www.w3.org/1999/xhtml", "style");
+ style.appendChild(document.createTextNode('.sound .tab-throbber {-moz-box-ordinal-group: 2!important; display: inline!important;}' +
+ '.sound .tab-throbber {list-style-image: url(' + data.url('sound.png') + ')}' +
+ '.sound .tab-icon-image {-moz-box-ordinal-group: 1!important;}' +
+ '.sound .tab-close-button{-moz-box-ordinal-group: 4!important;}' +
+ '.sound .tab-label {-moz-box-ordinal-group: 3!important;}'));
+ style.setAttribute("type", "text/css"),
+ document.documentElement.appendChild(style);
+ },
+ onUntrack: function(window) {}
+};
+tracker.init();
+
+function listenToMediaEvents(tab) {
+ var document = tab.contentDocument;
+ document.addEventListener("media", function(e) {
+ if (e.data == "sound") {
+ tab.innerTab.classList.add("sound");
+ }
+ if (e.data == "nosound") {
+ tab.innerTab.classList.remove("sound");
+ }
+ }, true);
+}
+
+var tabs = require("tabs");
+tabs.on('ready', function onOpen(tab) {
+ listenToMediaEvents(tab);
+});
+for each (var window in windows.browserWindows) {
+ for each (var tab in window.tabs) {
+ listenToMediaEvents(tab);
+ }
+}
+
+//
+// Page Mod for GrooveShark
+//
+
+var pageMod = require("page-mod");
+pageMod.PageMod({
+ include: "*.grooveshark.com",
+ contentScriptWhen: 'ready',
+ contentScript: '' +
+'window.console.log = function(m) {' +
+' if (m === "PLAY_STATUS_PAUSED") {' +
+' var evt = document.createEvent("MessageEvent");' +
+' evt.initMessageEvent("media", true, true, "nosound", document.location.href, "", window);' +
+' document.dispatchEvent(evt);' +
+'' +
+' }' +
+' if (m === "PLAY_STATUS_PLAYING") {' +
+' var evt = document.createEvent("MessageEvent");' +
+' evt.initMessageEvent("media", true, true, "sound", document.location.href, "", window);' +
+' document.dispatchEvent(evt);' +
+' }' +
+'};' +
+'window.addEventListener("media", function(e) {' +
+' if (e.data == "next") {' +
+' document.getElementById("player_next").click();' +
+' };' +
+' if (e.data == "play" || e.data == "stop") {' +
+' document.getElementById("player_play_pause").click();' +
+' };' +
+' if (e.data == "previous") {' +
+' document.getElementById("player_previous").click();' +
+' };' +
+'}, true)'
+});
@@ -0,0 +1,9 @@
+{
+ "name": "mediakeys",
+ "license": "MPL 1.1/GPL 2.0/LGPL 2.1",
+ "author": "",
+ "version": "0.1",
+ "fullName": "mediakeys",
+ "id": "jid0-xGz6L0RKy0LvnMYD4lyCUk4O60c",
+ "description": "brink media controls"
+}
@@ -0,0 +1 @@
+1.0b4
@@ -0,0 +1,30 @@
+Add-on SDK README
+==================
+
+Before proceeding, please make sure you've installed Python 2.5
+or 2.6 if it's not already on your system:
+
+ http://python.org/download/
+
+Note that Python 3.0 and 3.1 are not supported in this release.
+
+For Windows users, MozillaBuild (https://wiki.mozilla.org/MozillaBuild)
+will install the correct version of Python and the MSYS package, which
+will make it easier to work with the SDK.
+
+To get started, first enter the same directory that this README file
+is in (the SDK's root directory) using a shell program. On Unix systems
+or on Windows with MSYS, you can execute the following command:
+
+ source bin/activate
+
+Windows users using cmd.exe should instead run:
+
+ bin\activate.bat
+
+Then run:
+
+ cfx docs
+
+This should start a documentation server and open a web browser
+with further instructions.
@@ -0,0 +1,82 @@
+# This file must be used with "source bin/activate" *from bash*
+# you cannot run it directly
+
+deactivate () {
+ if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
+ PATH="$_OLD_VIRTUAL_PATH"
+ export PATH
+ unset _OLD_VIRTUAL_PATH
+ fi
+
+ # This should detect bash and zsh, which have a hash command that must
+ # be called to get it to forget past commands. Without forgetting
+ # past commands the $PATH changes we made may not be respected
+ if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
+ hash -r
+ fi
+
+ if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
+ PS1="$_OLD_VIRTUAL_PS1"
+ export PS1
+ unset _OLD_VIRTUAL_PS1
+ fi
+
+ if [ -n "$_OLD_PYTHONPATH" ] ; then
+ PYTHONPATH="$_OLD_PYTHONPATH"
+ export PYTHONPATH
+ unset _OLD_PYTHONPATH
+ fi
+
+ unset CUDDLEFISH_ROOT
+
+ unset VIRTUAL_ENV
+ if [ ! "$1" = "nondestructive" ] ; then
+ # Self destruct!
+ unset deactivate
+ fi
+}
+
+# unset irrelavent variables
+deactivate nondestructive
+
+_OLD_PYTHONPATH="$PYTHONPATH"
+_OLD_VIRTUAL_PATH="$PATH"
+
+VIRTUAL_ENV="`pwd`"
+
+if [ "x$OSTYPE" = "xmsys" ] ; then
+ CUDDLEFISH_ROOT="`pwd -W | sed s,/,\\\\\\\\,g`"
+ PATH="`pwd`/bin:$PATH"
+ # msys will convert any env vars with PATH in it to use msys
+ # form and will unconvert before launching
+ PYTHONPATH="`pwd -W`/python-lib;$PYTHONPATH"
+else
+ CUDDLEFISH_ROOT="$VIRTUAL_ENV"
+ PYTHONPATH="$VIRTUAL_ENV/python-lib:$PYTHONPATH"
+ PATH="$VIRTUAL_ENV/bin:$PATH"
+fi
+
+VIRTUAL_ENV="`pwd`"
+
+export CUDDLEFISH_ROOT
+export PYTHONPATH
+export PATH
+
+_OLD_VIRTUAL_PS1="$PS1"
+if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
+ # special case for Aspen magic directories
+ # see http://www.zetadev.com/software/aspen/
+ PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
+else
+ PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
+fi
+export PS1
+
+# This should detect bash and zsh, which have a hash command that must
+# be called to get it to forget past commands. Without forgetting
+# past commands the $PATH changes we made may not be respected
+if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
+ hash -r
+fi
+
+python -c "from jetpack_sdk_env import welcome; welcome()"
@@ -0,0 +1,82 @@
+@echo off
+set VIRTUAL_ENV=%CD%
+set CUDDLEFISH_ROOT=%VIRTUAL_ENV%
+
+SET WINCURVERKEY=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion
+REG QUERY "%WINCURVERKEY%" /v "ProgramFilesDir (x86)" >nul 2>nul
+if %ERRORLEVEL% EQU 0 (
+ SET WIN64=1
+) else (
+ SET WIN64=0
+)
+
+if "%WIN64%" EQU "1" (
+ SET PYTHONKEY=HKLM\SOFTWARE\Wow6432Node\Python\PythonCore
+) else (
+ SET PYTHONKEY=HKLM\SOFTWARE\Python\PythonCore
+)
+
+SET PYTHONVERSION=
+SET PYTHONINSTALL=
+
+if "%PYTHONVERSION%" EQU "" (
+ REG QUERY "%PYTHONKEY%\2.6\InstallPath" /ve >nul 2>nul
+ if %ERRORLEVEL% EQU 0 (
+ SET PYTHONVERSION=2.6
+ )
+)
+
+if "%PYTHONVERSION%" EQU "" (
+ REG QUERY "%PYTHONKEY%\2.5\InstallPath" /ve >nul 2>nul
+ if %ERRORLEVEL% EQU 0 (
+ SET PYTHONVERSION=2.5
+ )
+)
+
+if "%PYTHONVERSION%" EQU "" (
+ REG QUERY "%PYTHONKEY%\2.4\InstallPath" /ve >nul 2>nul
+ if %ERRORLEVEL% EQU 0 (
+ SET PYTHONVERSION=2.4
+ )
+)
+
+if "%PYTHONVERSION%" NEQ "" (
+ FOR /F "tokens=3* skip=1 delims= " %%A IN ('REG QUERY "%PYTHONKEY%\%PYTHONVERSION%\InstallPath" /ve') DO SET "PYTHONINSTALL=%%A"
+)
+
+if "%PYTHONINSTALL%" NEQ "" (
+ SET "PATH=%PATH%;%PYTHONINSTALL%"
+)
+
+if defined _OLD_PYTHONPATH (
+ set PYTHONPATH=%_OLD_PYTHONPATH%
+)
+if not defined PYTHONPATH (
+ set PYTHONPATH=;
+)
+set _OLD_PYTHONPATH=%PYTHONPATH%
+set PYTHONPATH=%VIRTUAL_ENV%\python-lib;%PYTHONPATH%
+
+if not defined PROMPT (
+ set PROMPT=$P$G
+)
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set PROMPT=%_OLD_VIRTUAL_PROMPT%
+)
+
+set _OLD_VIRTUAL_PROMPT=%PROMPT%
+set PROMPT=(%VIRTUAL_ENV%) %PROMPT%
+
+if defined _OLD_VIRTUAL_PATH (
+ set PATH=%_OLD_VIRTUAL_PATH%
+ goto SKIPPATH
+)
+set _OLD_VIRTUAL_PATH=%PATH%
+
+:SKIPPATH
+set PATH=%VIRTUAL_ENV%\bin;%PATH%
+
+python -c "from jetpack_sdk_env import welcome; welcome()"
+
+:END
@@ -0,0 +1,29 @@
+#! /usr/bin/env python
+
+import os
+import sys
+
+# set the cuddlefish "root directory" for this process if it's not already
+# set in the environment
+cuddlefish_root = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
+
+if 'CUDDLEFISH_ROOT' not in os.environ:
+ os.environ['CUDDLEFISH_ROOT'] = cuddlefish_root
+
+# add our own python-lib path to the python module search path.
+python_lib_dir = os.path.join(cuddlefish_root, "python-lib")
+if python_lib_dir not in sys.path:
+ sys.path.append(python_lib_dir)
+
+# now export to env so sub-processes get it too
+if 'PYTHONPATH' not in os.environ:
+ os.environ['PYTHONPATH'] = python_lib_dir
+elif python_lib_dir not in os.environ['PYTHONPATH'].split(os.pathsep):
+ paths = os.environ['PYTHONPATH'].split(os.pathsep)
+ paths.insert(0, python_lib_dir)
+ os.environ['PYTHONPATH'] = os.pathsep.join(paths)
+
+import cuddlefish
+
+if __name__ == '__main__':
+ cuddlefish.run()
@@ -0,0 +1,3 @@
+@echo off
+
+python "%VIRTUAL_ENV%\bin\cfx" %1 %2 %3 %4 %5 %6 %7 %8 %9
Oops, something went wrong.

0 comments on commit 5e05e52

Please sign in to comment.