From 34ce50a97c6527b65091ae9a57c94df92fea344e Mon Sep 17 00:00:00 2001 From: fgau Date: Wed, 7 Jan 2009 19:18:36 +0000 Subject: [PATCH] disable DeleteAllSms git-svn-id: http://www.neo1973-germany.de/svn@228 46df4e5c-bc4e-4628-a0fc-830ba316316d --- epydial/audio_screen.py | 51 +++ .../data/themes/blackwhite/audio_screen.edc | 346 ++++++++++++++++++ epydial/dialer_screen.py | 5 + epydial/epydial.py | 56 ++- epydial/weather_screen.py | 2 +- 5 files changed, 449 insertions(+), 11 deletions(-) create mode 100644 epydial/audio_screen.py create mode 100755 epydial/data/themes/blackwhite/audio_screen.edc diff --git a/epydial/audio_screen.py b/epydial/audio_screen.py new file mode 100644 index 0000000..e637ef4 --- /dev/null +++ b/epydial/audio_screen.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python2.5 +# -*- coding: utf-8 -*- +__author__ = "Soeren Apel (abraxa@dar-clan.de), Frank Gau (fgau@gau-net.de), Thomas Gstaedner (thomas (a) gstaedtner (.) net)" +__version__ = "prototype" +__copyright__ = "Copyright (c) 2008" +__license__ = "GPL3" + +from epydial import * + +class AudioScreen(EdjeGroup): + toggle = 0 + + def __init__(self, screen_manager): + EdjeGroup.__init__(self, screen_manager, AUDIO_SCREEN_NAME) + PyneoController.get_mp3_tags() + + def register_pyneo_callbacks(self): + PyneoController.register_callback("on_get_mp3_tags", self.on_get_mp3_tags) + + def on_get_mp3_tags(self, status): + self.part_text_set("mp3_tags", "artist: %s
album: %s
title: %s" % (status['artist'], status['album'], status['title'])) + + @edje.decorators.signal_callback("music_player_send", "*") + def on_edje_signal_audio_screen_triggered(self, emission, source): +# if source == "button_play_pause": +# self.signal_emit("button_play_pause", " ") +# PyneoController.pause_music() +# PyneoController.show_dialer_screen() + if source == "play_pause": + if self.toggle == 0: + self.signal_emit("key1", "") + PyneoController.play_music() + self.toggle = 1 + elif self.toggle == 1: + self.signal_emit("key2", "") + PyneoController.pause_music() + self.toggle = 0 + PyneoController.get_mp3_tags() + if source == "stop": + self.signal_emit("key2", "") + PyneoController.pause_music() + self.toggle = 0 + PyneoController.stop_music() + PyneoController.get_mp3_tags() + if source == "track_right": + PyneoController.next_music() + PyneoController.get_mp3_tags() + if source == "track_left": + PyneoController.previous_music() + PyneoController.get_mp3_tags() + print 'source: ', source diff --git a/epydial/data/themes/blackwhite/audio_screen.edc b/epydial/data/themes/blackwhite/audio_screen.edc new file mode 100755 index 0000000..c18e9c4 --- /dev/null +++ b/epydial/data/themes/blackwhite/audio_screen.edc @@ -0,0 +1,346 @@ +// audio_screen.edc +// this is a theme for epydial, a pyneo dialer and more + +data { + item: "author" "thomasg [thomas (a) gstaedtner (.) net] , fgau (fgau@gau-net.de)"; + item: "version" "prototype"; + item: "name" "epydial_blackwhite"; +} + +fonts { + font: "Vera.ttf" "Vera"; + font: "VeraBd.ttf" "VeraBd"; +} + +images { + image: "bg.png" COMP; + image: "play.png" COMP; + image: "pause.png" COMP; + image: "track_left.png" COMP; + image: "track_right.png" COMP; + image: "stop.png" COMP; +} + +color_classes { + color_class { + name: "unvisible"; + color: 0 0 0 0; + color2: 128 128 128 255; + color3: 128 128 128 255; + } + color_class { + name: "button_inactive"; + color: 255 255 255 128; + color2: 128 128 128 255; + color3: 128 128 128 255;; + } + color_class { + name: "scale"; + color: 255 255 255 64; + color2: 0 0 0 255; + color3: 0 0 0 255; + } +} + +styles { + style { + name: "textblock_style"; + base: "font=Vera font_size=20 align=left valign=top color=#fff"; + tag: "h1" "+ font_size=28"; + tag: "/h1" "- \n"; + tag: "p" "+"; + tag: "/p" "- \n"; + tag: "em" "+ style=underline underline_color=#000A underline2_color=#0005"; + tag: "/em" "-"; + tag: "br" "\n"; + tag: "c1" "+ color=#fff"; + tag: "/c1" "-"; + tag: "c2" "+ color=#f3f"; + tag: "/c2" "-"; + } +} + +#define key(n, x, y)\ +part {\ + name: n;\ + type: IMAGE;\ + description {\ + image {\ + normal: n".png";\ + }\ + rel1 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: -50 -50;\ + }\ + rel2 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: 50 50;\ + }\ + }\ +}\ +program { \ + name: "button_"n"_signal_emit"; \ + signal: "mouse,down,*"; \ + source: n; \ + action: SIGNAL_EMIT "music_player_send" n; \ +} \ + +#define key_play_pause(n, n1, n2, x, y)\ +part {\ + name: n;\ + type: IMAGE;\ + description {\ + state: "default" 0; \ + image {\ + normal: n1".png";\ + }\ + rel1 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: -50 -50;\ + }\ + rel2 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: 50 50;\ + }\ + }\ + description {\ + state: "default" 1; \ + image {\ + normal: n2".png";\ + }\ + rel1 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: -50 -50;\ + }\ + rel2 {\ + to: pad;\ + relative: (x+1)/4-1/8 (y+1)/5-1/10;\ + offset: 50 50;\ + }\ + }\ +}\ +program { \ + name: "button_"n"_signal_emit"; \ + signal: "mouse,down,*"; \ + source: n; \ + action: SIGNAL_EMIT "music_player_send" n; \ +} \ +program { \ + name: "press_key1"; \ + signal: "key1"; \ + action: STATE_SET "default" 1; \ + target: n; \ +} \ +program { \ + name: "press_key2"; \ + signal: "key2"; \ + action: STATE_SET "default" 0; \ + target: n; \ +} \ + +#define HBAR(barname, bordercolor, borderwidth, rel1x, rel1y, rel2x, rel2y, left_right_offset) \ +part { \ + name: "description_"barname; \ + type: TEXT; \ + mouse_events: 0; \ + description { \ + color_class: bordercolor; \ + rel1 { relative: rel1x rel1y; }; \ + rel2 { relative: rel2x rel2y; }; \ + text { \ + text: barname; \ + font: "VeraBd"; \ + size: 16; \ + } \ + } \ +} \ +part { \ + name: "button_left_bg_"barname; \ + type: RECT; \ + description { \ + state: "default" 0; \ + color_class: "unvisible"; \ + rel1 { relative: rel1x rel1y; offset: 0 0; }; \ + rel2 { relative: rel2x/4 rel2y; offset: 0 0; }; \ + } \ + description { \ + state: "default" 0.5; \ + inherit: "default" 0; \ + color_class: "unvisible"; \ + rel1.offset: 0 -5; \ + rel2.offset: 0 5; \ + } \ + description { \ + state: "default" 1; \ + inherit: "default" 0; \ + } \ +} \ +part { \ + name: "button_right_bg_"barname; \ + type: RECT; \ + description { \ + state: "default" 0; \ + color_class: "unvisible"; \ + rel1 { relative: 1-rel2x/4 rel1y; offset: 0 0; }; \ + rel2 { relative: rel2x rel2y; offset: 0 0; }; \ + } \ + description { \ + state: "default" 0.5; \ + inherit: "default" 0; \ + color_class: "unvisible"; \ + rel1.offset: 0 -5; \ + rel2.offset: 0 5; \ + } \ + description { \ + state: "default" 1; \ + inherit: "default" 0; \ + } \ +} \ +part { \ + name: "button_left_"barname; \ + type: TEXT; \ + mouse_events: 0; \ + description { \ + state: "default" 0; \ + color_class: bordercolor; \ + rel1 { to: "button_left_bg_"barname; relative: 0 0; }; \ + rel2 { to: "button_left_bg_"barname; relative: 1 1; }; \ + text { \ + text: "-"; \ + font: "VeraBd"; \ + size: 52; \ + fit: 1 1; \ + } \ + } \ +} \ +part { \ + name: "button_right_"barname; \ + type: TEXT; \ + mouse_events: 0; \ + description { \ + state: "default" 0; \ + color_class: bordercolor; \ + rel1 { to: "button_right_bg_"barname; relative: 0 0; }; \ + rel2 { to: "button_right_bg_"barname; relative: 1 1; }; \ + text { \ + text: "+"; \ + font: "VeraBd"; \ + size: 52; \ + fit: 1 1; \ + } \ + } \ +} \ +part { \ + name: "scale_fg_"barname; \ + type: RECT; \ + mouse_events: 0; \ + description { \ + color_class: scale; \ + rel1 { relative: rel2x/4 (rel1y+((rel2y-rel1y)/4)); }; \ + rel2 { relative: 1-rel2x/4 (rel2y-((rel2y-rel1y)/4)); }; \ + } \ +} \ +program { \ + name: "button_left_bg_"barname"_animation"; \ + signal: "mouse,down,*"; \ + source: "button_left_bg_"barname; \ + action: STATE_SET "default" 0.5; \ + target: "button_left_bg_"barname; \ +} \ +program { \ + name: "button_left_bg_"barname"_animation_end"; \ + signal: "mouse,up,*"; \ + source: "button_left_bg_"barname; \ + action: STATE_SET "default" 1; \ + target: "button_left_bg_"barname; \ + transition: DECELERATE 0.1; \ +} \ +program { \ + name: "button_right_bg_"barname"_animation"; \ + signal: "mouse,down,*"; \ + source: "button_right_bg_"barname; \ + action: STATE_SET "default" 0.5; \ + target: "button_right_bg_"barname; \ +} \ +program { \ + name: "button_right_bg_"barname"_animation_end"; \ + signal: "mouse,up,*"; \ + source: "button_right_bg_"barname; \ + action: STATE_SET "default" 1; \ + target: "button_right_bg_"barname; \ + transition: DECELERATE 0.1; \ +} \ + +collections { + group { + name: "pyneo/audio/screen"; + min: 100 100; + max: 800 800; + parts { + part { + name: "background"; + type: IMAGE; + mouse_events: 0; + description { + state: "default" 0; + rel1 { relative: 0 0; offset: 0 0; }; + rel2 { relative: 1 1; offset: 0 0; }; + image { normal: "bg.png"; }; + } + } + part { + name: "headline"; + type: TEXT; + description { + state: "default" 0; + color_class: "button_inactive"; + rel1 { relative: 1/20 1/20; } + rel2 { relative: 19/20 3/20; } + text { + text: "music"; + size: 20; + font: "VeraBd"; + fit: 1 1; + } + } + } + part { + name: "mp3_tags"; + type: TEXTBLOCK; + mouse_events: 0; + description { + color_class: "button_inactive"; + align: 0.5 0.5; + fixed: 1 1; + rel1 { relative: 0 4/20; } + rel2 { relative: 1 7/20; } + text { + text: ""; + style: "textblock_style"; + } + } + } + part { + name: "pad"; + type: RECT; + description { + visible: 0; + rel1 { relative: 0.0 1.0; offset: 25 -125; } + rel2 { relative: 1.0 1.0; offset: -25 -25; } + } + } + key("track_left", 0, 2) + key("stop", 1, 2) + key_play_pause("play_pause", "play", "pause", 2, 2) + key("track_right", 3, 2) + + HBAR("volume", button_inactive, 1, 0, 46/70, 1, 56/70, 10); + + } + } +} diff --git a/epydial/dialer_screen.py b/epydial/dialer_screen.py index 582cb23..1fbd063 100644 --- a/epydial/dialer_screen.py +++ b/epydial/dialer_screen.py @@ -152,6 +152,11 @@ class DialerScreen(EdjeGroup): self.text = [] self.part_text_set("numberdisplay_text", "".join(self.text)) PyneoController.show_sms_screen() + elif source == "dial" and ''.join(self.text) == "9": + print '--- Audio Screen' + self.text = [] + self.part_text_set("numberdisplay_text", "".join(self.text)) + PyneoController.show_audio_screen() elif source == "dial": PyneoController.show_incall_screen('outgoing') PyneoController.gsm_dial("".join(self.text)) diff --git a/epydial/epydial.py b/epydial/epydial.py index 15e2872..3673998 100755 --- a/epydial/epydial.py +++ b/epydial/epydial.py @@ -21,6 +21,7 @@ PIX_FILE_PATH = "/media/card/hon/" TRACK_FILE_PATH = "/media/card/track/" DB_FILE_PATH = "data/db/my.sqlite" PIX_WEATHER_FILE_PATH = "data/themes_data/blackwhite/images/stardock_weather/" +MP3_FILE_PATH = "/media/card/mp3/" DIALER_SCREEN_NAME = "pyneo/dialer/main" INCALL_SCREEN_NAME = "pyneo/dialer/incall" @@ -33,6 +34,7 @@ CONTACTS_SCREEN_NAME = "pyneo/contacts/screen" SMS_SCREEN_NAME = "pyneo/sms/screen" SMS_DETAIL_SCREEN_NAME = "pyneo/sms/detail" WEATHER_SCREEN_NAME = "pyneo/weather/screen" +AUDIO_SCREEN_NAME = "pyneo/audio/screen" from datetime import datetime from dbus import SystemBus @@ -88,6 +90,8 @@ class PyneoController(object): pwr = None gps = None hon = None + mp3 = None + mp3_music = None gsm_wireless = None gsm_keyring = None gsm_sms = None @@ -132,6 +136,7 @@ class PyneoController(object): class_.gps = object_by_url('dbus:///org/pyneo/GpsLocation') class_.hon = object_by_url('dbus:///org/pyneo/HotOrNot') class_.hon_hotornot = object_by_url(class_.hon.GetDevice('hotornot', dbus_interface=DIN_POWERED)) + class_.mp3 = object_by_url('dbus:///org/pyneo/Player') class_.call_type = 'nix' class_.brightness_value = 60 class_.call = None @@ -360,8 +365,8 @@ class PyneoController(object): @classmethod def show_dialer_screen(class_): -# class_.pwr.SetBrightness(class_.brightness_value, dbus_interface=DIN_POWER) -# class_.pwr.GetStatus(dbus_interface=DIN_POWERED) + class_.pwr.SetBrightness(class_.brightness_value, dbus_interface=DIN_POWER) + class_.pwr.GetStatus(dbus_interface=DIN_POWERED) class_.notify_callbacks("show_dialer_screen") @classmethod @@ -415,24 +420,18 @@ class PyneoController(object): def CallStatus(newmap): newmap = dedbusmap(newmap) print '---', 'CallStatus' -# for n, v in newmap.items(): -# print '\t', n, ':', v def CallRing(newmap): newmap = dedbusmap(newmap) class_.notify_callbacks("gsm_phone_ringing") if newmap['number']: class_.notify_callbacks("gsm_number_display", newmap['number']) print '---', 'CallRing' -# for n, v in newmap.items(): -# print '\t', n, ':', v def CallEnd(newmap): class_.notify_callbacks("gsm_phone_call_end") os.system('alsactl -f /usr/share/openmoko/scenarios/stereoout.state restore') newmap = dedbusmap(newmap) print '---', 'CallEnd' -# for n, v in newmap.items(): -# print '\t', n, ':', v if class_.call: class_.call = None while class_.callsigs: @@ -463,7 +462,7 @@ class PyneoController(object): content = dedbusmap(sm.GetContent()) InsertSms('REC UNREAD', content['from_msisdn'], content['time'], content['text'].encode('utf-8')) print '--- NEW SMS:', content['from_msisdn'], content['time'], content['text'].encode('utf-8') - class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE) +# class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE) @classmethod def first_check_new_sms(class_): @@ -482,7 +481,7 @@ class PyneoController(object): InsertSms('REC UNREAD', content['from_msisdn'], content['time'], content['text'].encode('utf-8')) except: print '--- NULL new sms' - class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE) +# class_.gsm_sms.DeleteAll(dbus_interface=DIN_STORAGE) @classmethod def show_sms_screen(class_): @@ -504,6 +503,37 @@ class PyneoController(object): def vibrate_stop(class_): class_.pwr.Vibrate(0, 0, 0, dbus_interface=DIN_POWER) + @classmethod + def show_audio_screen(class_): + class_.notify_callbacks("show_audio_screen") + + @classmethod + def play_music(class_): + class_.mp3.Play(dbus_interface='org.pyneo.Music') + + @classmethod + def stop_music(class_): + class_.mp3.Stop(dbus_interface='org.pyneo.Music') + + @classmethod + def pause_music(class_): + class_.mp3.Pause(dbus_interface='org.pyneo.Music') + + @classmethod + def next_music(class_): + class_.mp3.Next(dbus_interface='org.pyneo.Music') + + @classmethod + def previous_music(class_): + class_.mp3.Previous(dbus_interface='org.pyneo.Music') + + @classmethod + def set_playlist_from_dir(class_): + class_.mp3.SetPlaylistFromDir(MP3_FILE_PATH, dbus_interface='org.pyneo.Music') + + @classmethod + def get_mp3_tags(class_): + class_.notify_callbacks("on_get_mp3_tags", class_.mp3.GetStatus(dbus_interface='org.pyneo.Music')) from dialer_screen import * from incall_screen import * @@ -516,6 +546,7 @@ from contacts_screen import * from sms_screen import * from sms_detail import * from weather_screen import * +from audio_screen import * class Dialer(object): screens = None @@ -543,6 +574,7 @@ class Dialer(object): PyneoController.register_callback("show_sms_screen", self.on_sms_screen) PyneoController.register_callback("show_sms_screen_detail", self.on_sms_screen_detail) PyneoController.register_callback("show_weather_screen", self.on_weather_screen) + PyneoController.register_callback("show_audio_screen", self.on_audio_screen) # Initialize the D-Bus interface to pyneo dbus_ml = e_dbus.DBusEcoreMainLoop() @@ -555,6 +587,7 @@ class Dialer(object): self.init_screen(GSM_STATUS_SCREEN_NAME, GsmStatusScreen(self)) self.init_screen(GPS_STATUS_SCREEN_NAME, GpsStatusScreen(self)) + PyneoController.set_playlist_from_dir() PyneoController.power_up_gsm() PyneoController.get_gsm_keyring() @@ -621,6 +654,9 @@ class Dialer(object): self.init_screen(WEATHER_SCREEN_NAME, WeatherScreen(self)) self.show_screen(WEATHER_SCREEN_NAME) + def on_audio_screen(self): + self.init_screen(AUDIO_SCREEN_NAME, AudioScreen(self)) + self.show_screen(AUDIO_SCREEN_NAME) class EvasCanvas(object): def __init__(self, fullscreen, engine_name): diff --git a/epydial/weather_screen.py b/epydial/weather_screen.py index 1cf3a09..f713a1a 100644 --- a/epydial/weather_screen.py +++ b/epydial/weather_screen.py @@ -5,7 +5,7 @@ __version__ = "prototype" __copyright__ = "Copyright (c) 2008" __license__ = "GPL3" -ZIP_CODE = 'GMXX0007' #GMXX0007 Berlin, GMXX0049 Hamburg +ZIP_CODE = 'GMXX0049' #GMXX0007 Berlin, GMXX0049 Hamburg TEMP_UNIT = 'c' WEATHER_URL = 'http://xml.weather.yahoo.com/forecastrss?p=%s&u=%s'