Obmocmenu: Music on Console (moc) pipe menu for Openbox

Sourceforge Project Page
AUR Package
Screenshot
This is a simple menu for controlling the music player moc. I use moc version 2.5.0-alpha4 (found in the AUR) which has quite a few more features than 2.4.4 in [extra]. Still, this script should work fine with the moc in the official repos.
You may also be interested in obdevicemenu: Udisks pipe menu for Openbox.
Let me know if there are any bugs, or any additions or improvements you'd like to see.
Last edited by jnguyen (2011-03-10 15:31:57)

0.8.4 released, with the ability to add a random album/directory/song to the playlist, a feature which moc itself is missing. If zenity is installed, a dialog box pops up that allows you to add the specified number of random entries (e.g. 3 random albums). See the configuration file for details.

Similar Messages

  • EeePc control (pipe menu)

    Here is a simple pipe menu script to control some eeePc features:
    cpu governors\frequence (cpufreq-utils)
    bluetooth, touchpad, webcam and card reader (acpi-eeepc-generic).
    tested on an eeePc 1000H.
    ## ozzolo's eee-control pipe menu for Openbox
    ## v 0.2
    ## tested on Asus eeePC 1000H
    ## 1) copy the script in ~/.config/openbox/pipemenus/eee-control.sh
    ## 2) change permissions: "chmod +x ~/.config/openbox/pipemenus/eee-control.sh"
    ## 3) edit ~/.config/openbox/menu.xml
    ## add <menu execute="~/.config/openbox/pipemenus/eee-control.sh" id="eee-control" label="eee control"/>
    ## 4) edit /etc/sudoers: "sudo EDITOR=nano visudo"
    ## add <your_username> ALL=NOPASSWD: /usr/bin/cpufreq-set, /etc/acpi/eeepc/
    echo "<openbox_pipe_menu>"
    CPUmodel=$(cat /proc/cpuinfo | grep -m 1 "model name" | sed 's/.*: \| \|(R)\|(TM)//g')
    EEEPCmodel=$(cat /etc/conf.d/acpi-eeepc-generic.conf | grep -m 1 "EEEPC_MODEL" | sed 's/.*=\|"//g')
    echo "<separator label=\"Asus EEEPC $EEEPCmodel $CPUmodel\"/>"
    # CPU - cpufreq-utils #
    CPU0gov=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
    CPU1gov=$(cat /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor)
    availGOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)
    availFREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies)
    CPUfreq=$(cat /proc/cpuinfo | grep -m 2 "cpu MHz" | sed 's/.*: \|.000//g')
    echo "<menu id=\"eeecontrol-cpu\" label=\"CPU: $CPU0gov/$CPU1gov - $CPUfreq Mhz\">"
    i=1
    for xgov in $availGOV
    do
    if [ $xgov = "userspace" ]
    then
    j=1
    for xfreq in $availFREQ
    do
    xfreq=`expr $xfreq / 1000`
    echo "<item label=\"set: $xgov $xfreq Mhz\"><action name=\"Execute\"><execute>sudo cpufreq-set -c 0 -f $xfreq</execute></action><action name=\"Execute\"><execute>sudo cpufreq-set -c 1 -f $xfreq</execute></action></item>"
    let "j+=1"
    done
    else
    echo "<item label=\"set: $xgov\"><action name=\"Execute\"><execute>sudo cpufreq-set -c 0 -g $xgov</execute></action><action name=\"Execute\"><execute>sudo cpufreq-set -c 1 -g $xgov</execute></action></item>"
    let "i+=1"
    fi
    done
    echo "</menu>"
    # CPU end #
    # ACPI - acpi-eeepc-generic #
    statesDIR=/var/eeepc/states
    scriptsDIR=/etc/acpi/eeepc
    TPstate=$(cat $statesDIR/touchpad | sed 's/0/Off/' | sed 's/1/On/')
    echo "<item label=\"toggle Touchpad (now $TPstate) \"><action name=\"Execute\"><execute>sudo $scriptsDIR/acpi-eeepc-generic-toggle-touchpad.sh</execute></action></item>"
    BTstate=$(cat $statesDIR/bluetooth | sed 's/0/Off/' | sed 's/1/On/')
    echo "<item label=\"toggle Bluetooth (now $BTstate) \"><action name=\"Execute\"><execute>sudo $scriptsDIR/acpi-eeepc-generic-toggle-bluetooth.sh</execute></action></item>"
    CAMstate=$(cat $statesDIR/camera | sed 's/0/Off/' | sed 's/1/On/')
    echo "<item label=\"toggle Webcam (now $CAMstate) \"><action name=\"Execute\"><execute>sudo $scriptsDIR/acpi-eeepc-generic-toggle-webcam.sh</execute></action></item>"
    CARDstate=$(cat $statesDIR/cardr | sed 's/0/Off/' | sed 's/1/On/')
    echo "<item label=\"toggle Card Reader (now $CARDstate) \"><action name=\"Execute\"><execute>sudo $scriptsDIR/acpi-eeepc-generic-toggle-cardr.sh</execute></action></item>"
    # ACPI end #
    echo "</openbox_pipe_menu>"

    That's really strange.
    It's telling you that there is something wrong in your sed expression, I believe the thermal one:
    sed -nr "s/.*(\<[[:digit:]]+\.[[:digit:]]) degrees.*/\1°C/p"
    For what it's worth, this runs correctly on my machine. You don't have some odd version of sed, do you?
    I also don't understand why the 'Battery' and 'Thermal' variables in the script are not being substituted in the echo commands. You haven't substituted single quotes for double quotes in the script, have you? In other words, you haven't done this:
    echo '<openbox_pipe_menu>'
    echo ' <item label="Battery: $Battery"/>'
    echo ' <item label="Temperature: $Thermal"/>'
    echo '</openbox_pipe_menu>'
    This wouldn't work since the variables wouldn't be substituted correctly.  Bash doesn't substitute the variable values within single quotes. The middle two echo's have to be like this:
    echo " <item label=\"Battery: $Battery\"/>"
    echo " <item label=\"Temperature: $Thermal\"/>"
    or like this:
    printf ' <item label="Battery: %s"/>\n' "$Battery"
    printf ' <item label="Temperature: %s"/>\n' "$Thermal"

  • Scan for and connect to networks from an openbox pipe menu (netcfg)

    So the other day when i was using wifi-select (awesome tool) to connect to a friends hot-spot, i realized "hey! this would be great as an openbox pipe menu."  i'm fairly decent in bash and i knew both netcfg and wifi-select were in bash so why not rewrite it that way?
    Wifi-Pipe
    A simplified version of wifi-select which will scan for networks and populate an openbox right-click menu item with available networks.  displays security type and signal strength.  click on a network to connect via netcfg the same way wifi-select does it.
    zenity is used to ask for a password and notify of a bad connection.  one can optionally remove the netcfg profile if the connection fails.
    What's needed
    -- you have to be using netcfg to manage your wireless
    -- you have to install zenity
    -- you have to save the script as ~/.config/openbox/wifi-pipe and make it executable:
    chmod +x ~/.config/openbox/wifi-pipe
    -- you have to add a sudoers entry to allow passwordless sudo on this script and netcfg (!)
    USERNAME ALL=(ALL) NOPASSWD: /usr/bin/netcfg
    USERNAME ALL=(ALL) NOPASSWD: /home/USERNAME/.config/openbox/wifi-pipe
    -- you have to adjust  ~/.config/openbox/menu.xml like so:
    <menu id="root-menu" label="Openbox 3">
    <menu id="pipe-wifi" label="Wifi" execute="sudo /home/USERNAME/.config/openbox/wifi-pipe INTERFACE" />
    <menu id="term-menu"/>
    <item label="Run...">
    <action name="Execute">
    <command>gmrun</command>
    </action>
    </item>
    where USERNAME is you and INTERFACE is probably wlan0 or similar
    openbox --reconfigure and you should be good to go.
    The script
    #!/bin/bash
    # pbrisbin 2009
    # simplified version of wifi-select designed to output as an openbox pipe menu
    # required:
    # netcfg
    # zenity
    # NOPASSWD entries for this and netcfg through visudo
    # the following in menu.xml:
    # <menu id="pipe-wifi" label="Wifi" execute="sudo /path/to/wifi.pipe interface"/>
    # the idea is to run this script once to scan/print, then again immediately to connect.
    # therefore, if you scan but don't connect, a temp file is left in /tmp. the next scan
    # will overwrite it, and the next connect will remove it.
    # source this just to get PROFILE_DIR
    . /usr/lib/network/network
    [ -z "$PROFILE_DIR" ] && PROFILE_DIR='/etc/network.d/'
    # awk code for parsing iwlist output
    # putting it here removes the wifi-select dependency
    # and allows for my own tweaking
    # prints a list "essid=security=quality_as_percentage"
    PARSER='
    BEGIN { FS=":"; OFS="="; }
    /\<Cell/ { if (essid) print essid, security, quality[2]/quality[3]*100; security="none" }
    /\<ESSID:/ { essid=substr($2, 2, length($2) - 2) } # discard quotes
    /\<Quality=/ { split($1, quality, "[=/]") }
    /\<Encryption key:on/ { security="wep" }
    /\<IE:.*WPA.*/ { security="wpa" }
    END { if (essid) print essid, security, quality[2]/quality[3]*100 }
    errorout() {
    echo "<openbox_pipe_menu>"
    echo "<item label=\"$1\" />"
    echo "</openbox_pipe_menu>"
    exit 1
    create_profile() {
    ESSID="$1"; INTERFACE="$2"; SECURITY="$3"; KEY="$4"
    PROFILE_FILE="$PROFILE_DIR$ESSID"
    cat > "$PROFILE_FILE" << END_OF_PROFILE
    CONNECTION="wireless"
    ESSID="$ESSID"
    INTERFACE="$INTERFACE"
    DESCRIPTION="Automatically generated profile"
    SCAN="yes"
    IP="dhcp"
    TIMEOUT="10"
    SECURITY="$SECURITY"
    END_OF_PROFILE
    # i think wifi-select should adopt these perms too...
    if [ -n "$KEY" ]; then
    echo "KEY=\"$KEY\"" >> "$PROFILE_FILE"
    chmod 600 "$PROFILE_FILE"
    else
    chmod 644 "$PROFILE_FILE"
    fi
    print_menu() {
    # scan for networks
    iwlist $INTERFACE scan 2>/dev/null | awk "$PARSER" | sort -t= -nrk3 > /tmp/networks.tmp
    # exit if none found
    if [ ! -s /tmp/networks.tmp ]; then
    rm /tmp/networks.tmp
    errorout "no networks found."
    fi
    # otherwise print the menu
    local IFS='='
    echo "<openbox_pipe_menu>"
    while read ESSID SECURITY QUALITY; do
    echo "<item label=\"$ESSID ($SECURITY) ${QUALITY/.*/}%\">" # trim decimals
    echo " <action name=\"Execute\">"
    echo " <command>sudo $0 $INTERFACE connect \"$ESSID\"</command>"
    echo " </action>"
    echo "</item>"
    done < /tmp/networks.tmp
    echo "</openbox_pipe_menu>"
    connect() {
    # check for an existing profile
    PROFILE_FILE="$(grep -REl "ESSID=[\"']?$ESSID[\"']?" "$PROFILE_DIR" | grep -v '~$' | head -n1)"
    # if found use it, else create a new profile
    if [ -n "$PROFILE_FILE" ]; then
    PROFILE=$(basename "$PROFILE_FILE")
    else
    PROFILE="$ESSID"
    SECURITY="$(awk -F '=' "/$ESSID/"'{print $2}' /tmp/networks.tmp | head -n1)"
    # ask for the security key if needed
    if [ "$SECURITY" != "none" ]; then
    KEY="$(zenity --entry --title="Authentication" --text="Please enter $SECURITY key for $ESSID" --hide-text)"
    fi
    # create the new profile
    create_profile "$ESSID" "$INTERFACE" "$SECURITY" "$KEY"
    fi
    # connect
    netcfg2 "$PROFILE" >/tmp/output.tmp
    # if failed, ask about removal of created profile
    if [ $? -ne 0 ]; then
    zenity --question \
    --title="Connection failed" \
    --text="$(grep -Eo "[\-\>]\ .*$" /tmp/output.tmp) \n Remove $PROFILE_FILE?" \
    --ok-label="Remove profile"
    [ $? -eq 0 ] && rm $PROFILE_FILE
    fi
    rm /tmp/output.tmp
    rm /tmp/networks.tmp
    [ $(id -u) -ne 0 ] && errorout "root access required."
    [ -z "$1" ] && errorout "usage: $0 [interface]"
    INTERFACE="$1"; shift
    # i added a sleep if we need to explicitly bring it up
    # b/c youll get "no networks found" when you scan right away
    # this only happens if we aren't up already
    if ! ifconfig | grep -q $INTERFACE; then
    ifconfig $INTERFACE up &>/dev/null || errorout "$INTERFACE not up"
    while ! ifconfig | grep -q $INTERFACE; do sleep 1; done
    fi
    if [ "$1" = "connect" ]; then
    ESSID="$2"
    connect
    else
    print_menu
    fi
    Screenshots
    removed -- Hi-res shots available on my site
    NOTE - i have not tested this extensively but it was working for me in most cases.  any updates/fixes will be edited right into this original post.  enjoy!
    UPDATE - 10/24/2009: i moved the awk statement from wifi-select directly into the script.  this did two things: wifi-select is no longer needed on the system, and i could tweak the awk statement to be more accurate.  it now prints a true percentange.  iwlist prints something like Quality=17/70 and the original awk statement would just output 17 as the quality.  i changed to print (17/70)*100 then bash trims the decimals so you get a true percentage.
    Last edited by brisbin33 (2010-05-09 01:28:20)

    froli wrote:
    I think the script's not working ... When I type
    sh wifi-pipe
    in a term it returns nothing
    well, just to be sure you're doing it right...
    he above is only an adjustment to the OB script's print_menu() function, it's not an entire script to itself.  so, if the original OB script shows output for you with
    sh ./wifi-pipe
    then using the above pint_menu() function (with all the other supporting code) should also show output, (only really only changes the echo's so they print the info in the pekwm format).
    oh, and if neither version shows output when you rut it in a term, then you've got other issues... ;P
    here's an entire [untested] pekwm script:
    #!/bin/bash
    # pbrisbin 2009
    # simplified version of wifi-select designed to output as an pekwm pipe menu
    # required:
    # netcfg
    # zenity
    # NOPASSWD entries for this and netcfg through visudo
    # the following in pekwm config file:
    # SubMenu = "WiFi" {
    # Entry = { Actions = "Dynamic /path/to/wifi-pipe" }
    # the idea is to run this script once to scan/print, then again immediately to connect.
    # therefore, if you scan but don't connect, a temp file is left in /tmp. the next scan
    # will overwrite it, and the next connect will remove it.
    # source this to get PROFILE_DIR and SUBR_DIR
    . /usr/lib/network/network
    errorout() {
    echo "Dynamic {"
    echo " Entry = \"$1\""
    echo "}"
    exit 1
    create_profile() {
    ESSID="$1"; INTERFACE="$2"; SECURITY="$3"; KEY="$4"
    PROFILE_FILE="$PROFILE_DIR$ESSID"
    cat > "$PROFILE_FILE" << END_OF_PROFILE
    CONNECTION="wireless"
    ESSID="$ESSID"
    INTERFACE="$INTERFACE"
    DESCRIPTION="Automatically generated profile"
    SCAN="yes"
    IP="dhcp"
    TIMEOUT="10"
    SECURITY="$SECURITY"
    END_OF_PROFILE
    # i think wifi-select should adopt these perms too...
    if [ -n "$KEY" ]; then
    echo "KEY=\"$KEY\"" >> "$PROFILE_FILE"
    chmod 600 "$PROFILE_FILE"
    else
    chmod 644 "$PROFILE_FILE"
    fi
    print_menu() {
    # scan for networks
    iwlist $INTERFACE scan 2>/dev/null | awk -f $SUBR_DIR/parse-iwlist.awk | sort -t= -nrk3 > /tmp/networks.tmp
    # exit if none found
    if [ ! -s /tmp/networks.tmp ]; then
    rm /tmp/networks.tmp
    errorout "no networks found."
    fi
    # otherwise print the menu
    echo "Dynamic {"
    IFS='='
    cat /tmp/networks.tmp | while read ESSID SECURITY QUALITY; do
    echo "Entry = \"$ESSID ($SECURITY) $QUALITY%\" {"
    echo " Actions = \"Exec sudo $0 $INTERFACE connect \\\"$ESSID\\\"\"</command>"
    echo "}"
    done
    unset IFS
    echo "}"
    connect() {
    # check for an existing profile
    PROFILE_FILE="$(grep -REl "ESSID=[\"']?$ESSID[\"']?" "$PROFILE_DIR" | grep -v '~$' | head -n1)"
    # if found use it, else create a new profile
    if [ -n "$PROFILE_FILE" ]; then
    PROFILE=$(basename "$PROFILE_FILE")
    else
    PROFILE="$ESSID"
    SECURITY="$(awk -F '=' "/$ESSID/"'{print $2}' /tmp/networks.tmp | head -n1)"
    # ask for the security key if needed
    if [ "$SECURITY" != "none" ]; then
    KEY="$(zenity --entry --title="Authentication" --text="Please enter $SECURITY key for $ESSID" --hide-text)"
    fi
    # create the new profile
    create_profile "$ESSID" "$INTERFACE" "$SECURITY" "$KEY"
    fi
    # connect
    netcfg2 "$PROFILE" >/tmp/output.tmp
    # if failed, ask about removal of created profile
    if [ $? -ne 0 ]; then
    zenity --question \
    --title="Connection failed" \
    --text="$(grep -Eo "[\-\>]\ .*$" /tmp/output.tmp) \n Remove $PROFILE_FILE?" \
    --ok-label="Remove profile"
    [ $? -eq 0 ] && rm $PROFILE_FILE
    fi
    rm /tmp/output.tmp
    rm /tmp/networks.tmp
    [ $(id -u) -ne 0 ] && errorout "root access required."
    [ -z "$1" ] && errorout "usage: $0 [interface]"
    INTERFACE="$1"; shift
    # i added a sleep if we need to explicitly bring it up
    # b/c youll get "no networks found" when you scan right away
    # this only happens if we aren't up already
    if ! ifconfig | grep -q $INTERFACE; then
    ifconfig $INTERFACE up &>/dev/null || errorout "$INTERFACE not up"
    sleep 3
    fi
    if [ "$1" = "connect" ]; then
    ESSID="$2"
    connect
    else
    print_menu
    fi
    exit 0

  • My media drop menu for music, tv shows, etc. is missing in iTunes?

    My media drop menu for music, tv shows, etc. is missing in iTunes?

    A lot of it may be artwork. My iTunes is 40,000 songs (213Gb and I have almost 9Gb of artwork - and that's been downsized to 300X300 "web optimized" images too)
    Also, there is a discrepancy between the way iTunes shows files size and the way OS X does.
    iTunes (most likely because there is also a Windows version) uses "binary" calculations (1mb = 1024kb and so on) where OS X uses "decimal" calculation (1mb = 1000kb and so on).
    120gGb in iTunes is 122,880mb. That same 120Gb in OS X is 120,000mb.
    The files are the same size, but OS X will show more available space than iTunes will.
    Still, artwork and duplicates are the #1 & #2 culprits. 
    Lastly, the bit rate of your music can be a factor. If everything is 320kbps or more... or Apple Lossless (800kbps+ usually) your music files are a lot bigger than you probably need, unless you're a music professional (DJ or producer). Try converting them down to a bit rate in the area of 160 or 192kbps. 192 is the MAX for anything in my library, because I only use it for home listening.

  • Music On Console Tray Icon

    MocIcon
    http://mocicon.archuser.com
    Today, I wrote a program called MocIcon *music on console icon* which is a gtk app written in C that gives you access to basic moc functions in the tray.
    Inspired by Moc-tray, I wrote this app primarily because I hate Perl, so bloated and heavy, so i decided to write a nice little GTK app in C (under 100 SLOC)
    features:
    -Start/Stop Server
    -Play/Pause song
    -Next/Previous
    upcoming features:
    -Icons for the items using GTK's stock icons
    -Information with notify-send.
    -Rewrite of redundant parts (if you read the code you'll get it)
    -Mouse over for current song
    I don't have anywere to store it, but it's small so i'll include it here, To compile it run:
    gcc -Wall -g mocicon.c -o mocicon `pkg-config --cflags --libs gtk+-2.0`
    Comments and Suggestions would be greatly appreciated!
    -Calvin
    Last edited by crazycal00 (2009-12-16 01:12:30)

    Version 0.1.1 is out!
    fixed a few bugs, cleaned up code
    get it:
    http://mocicon.archuser.com/source/moci … .1.tar.bz2
    Last edited by crazycal00 (2009-12-16 00:51:18)

  • Python openbox pipe menu

    I somewhat hijacked a different thread and my question is more suited here.
    I'm using a python script to check gmail in a pipe menu. At first it was creating problems because it would create a cache but would then not load until the file was removed. To fix this, I removed the last line (which created the cache) and it all works. However, I would prefer to have it work like it was intended.
    The script:
    #!/usr/bin/python
    # Authors: [email protected] [email protected]
    # License: GPL 2.0
    # Usage:
    # Put an entry in your ~/.config/openbox/menu.xml like this:
    # <menu id="gmail" label="gmail" execute="~/.config/openbox/scripts/gmail-openbox.py" />
    # And inside <menu id="root-menu" label="openbox">, add this somewhere (wherever you want it on your menu)
    # <menu id="gmail" />
    import os
    import sys
    import logging
    name = "111111"
    pw = "000000"
    browser = "firefox3"
    filename = "/tmp/.gmail.cache"
    login = "\'https://mail.google.com/mail\'"
    # Allow us to run using installed `libgmail` or the one in parent directory.
    try:
    import libgmail
    except ImportError:
    # Urghhh...
    sys.path.insert(1,
    os.path.realpath(os.path.join(os.path.dirname(__file__),
    os.path.pardir)))
    import libgmail
    if __name__ == "__main__":
    import sys
    from getpass import getpass
    if not os.path.isfile(filename):
    ga = libgmail.GmailAccount(name, pw)
    try:
    ga.login()
    except libgmail.GmailLoginFailure:
    print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    print "<openbox_pipe_menu>"
    print " <item label=\"login failed.\">"
    print " <action name=\"Execute\"><execute>" + browser + " " + login + "</execute></action>"
    print " </item>"
    print "</openbox_pipe_menu>"
    raise SystemExit
    else:
    ga = libgmail.GmailAccount(
    state = libgmail.GmailSessionState(filename = filename))
    msgtotals = ga.getUnreadMsgCount()
    print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    print "<openbox_pipe_menu>"
    print "<separator label=\"Gmail\"/>"
    if msgtotals == 0:
    print " <item label=\"no new messages.\">"
    elif msgtotals == 1:
    print " <item label=\"1 new message.\">"
    else:
    print " <item label=\"" + str(msgtotals) + " new messages.\">"
    print " <action name=\"Execute\"><execute>" + browser + " " + login + "</execute></action>"
    print " </item>"
    print "</openbox_pipe_menu>"
    state = libgmail.GmailSessionState(account = ga).save(filename)
    The line I removed:
    state = libgmail.GmailSessionState(account = ga).save(filename)
    The error I'd get if the cache existed:
    Traceback (most recent call last):
    File "/home/shawn/.config/openbox/scripts/gmail.py", line 56, in <module>
    msgtotals = ga.getUnreadMsgCount()
    File "/home/shawn/.config/openbox/scripts/libgmail.py", line 547, in getUnreadMsgCount
    q = "is:" + U_AS_SUBSET_UNREAD)
    File "/home/shawn/.config/openbox/scripts/libgmail.py", line 428, in _parseSearchResult
    return self._parsePage(_buildURL(**params))
    File "/home/shawn/.config/openbox/scripts/libgmail.py", line 401, in _parsePage
    items = _parsePage(self._retrievePage(urlOrRequest))
    File "/home/shawn/.config/openbox/scripts/libgmail.py", line 369, in _retrievePage
    if self.opener is None:
    AttributeError: GmailAccount instance has no attribute 'opener'
    EDIT - you might need the libgmail.py
    #!/usr/bin/env python
    # libgmail -- Gmail access via Python
    ## To get the version number of the available libgmail version.
    ## Reminder: add date before next release. This attribute is also
    ## used in the setup script.
    Version = '0.1.8' # (Nov 2007)
    # Original author: [email protected]
    # Maintainers: Waseem ([email protected]) and Stas Z ([email protected])
    # License: GPL 2.0
    # NOTE:
    # You should ensure you are permitted to use this script before using it
    # to access Google's Gmail servers.
    # Gmail Implementation Notes
    # ==========================
    # * Folders contain message threads, not individual messages. At present I
    # do not know any way to list all messages without processing thread list.
    LG_DEBUG=0
    from lgconstants import *
    import os,pprint
    import re
    import urllib
    import urllib2
    import mimetypes
    import types
    from cPickle import load, dump
    from email.MIMEBase import MIMEBase
    from email.MIMEText import MIMEText
    from email.MIMEMultipart import MIMEMultipart
    GMAIL_URL_LOGIN = "https://www.google.com/accounts/ServiceLoginBoxAuth"
    GMAIL_URL_GMAIL = "https://mail.google.com/mail/?ui=1&"
    # Set to any value to use proxy.
    PROXY_URL = None # e.g. libgmail.PROXY_URL = 'myproxy.org:3128'
    # TODO: Get these on the fly?
    STANDARD_FOLDERS = [U_INBOX_SEARCH, U_STARRED_SEARCH,
    U_ALL_SEARCH, U_DRAFTS_SEARCH,
    U_SENT_SEARCH, U_SPAM_SEARCH]
    # Constants with names not from the Gmail Javascript:
    # TODO: Move to `lgconstants.py`?
    U_SAVEDRAFT_VIEW = "sd"
    D_DRAFTINFO = "di"
    # NOTE: All other DI_* field offsets seem to match the MI_* field offsets
    DI_BODY = 19
    versionWarned = False # If the Javascript version is different have we
    # warned about it?
    RE_SPLIT_PAGE_CONTENT = re.compile("D\((.*?)\);", re.DOTALL)
    class GmailError(Exception):
    Exception thrown upon gmail-specific failures, in particular a
    failure to log in and a failure to parse responses.
    pass
    class GmailSendError(Exception):
    Exception to throw if we're unable to send a message
    pass
    def _parsePage(pageContent):
    Parse the supplied HTML page and extract useful information from
    the embedded Javascript.
    lines = pageContent.splitlines()
    data = '\n'.join([x for x in lines if x and x[0] in ['D', ')', ',', ']']])
    #data = data.replace(',,',',').replace(',,',',')
    data = re.sub(',{2,}', ',', data)
    result = []
    try:
    exec data in {'__builtins__': None}, {'D': lambda x: result.append(x)}
    except SyntaxError,info:
    print info
    raise GmailError, 'Failed to parse data returned from gmail.'
    items = result
    itemsDict = {}
    namesFoundTwice = []
    for item in items:
    name = item[0]
    try:
    parsedValue = item[1:]
    except Exception:
    parsedValue = ['']
    if itemsDict.has_key(name):
    # This handles the case where a name key is used more than
    # once (e.g. mail items, mail body etc) and automatically
    # places the values into list.
    # TODO: Check this actually works properly, it's early... :-)
    if len(parsedValue) and type(parsedValue[0]) is types.ListType:
    for item in parsedValue:
    itemsDict[name].append(item)
    else:
    itemsDict[name].append(parsedValue)
    else:
    if len(parsedValue) and type(parsedValue[0]) is types.ListType:
    itemsDict[name] = []
    for item in parsedValue:
    itemsDict[name].append(item)
    else:
    itemsDict[name] = [parsedValue]
    return itemsDict
    def _splitBunches(infoItems):# Is this still needed ?? Stas
    Utility to help make it easy to iterate over each item separately,
    even if they were bunched on the page.
    result= []
    # TODO: Decide if this is the best approach.
    for group in infoItems:
    if type(group) == tuple:
    result.extend(group)
    else:
    result.append(group)
    return result
    class SmartRedirectHandler(urllib2.HTTPRedirectHandler):
    def __init__(self, cookiejar):
    self.cookiejar = cookiejar
    def http_error_302(self, req, fp, code, msg, headers):
    # The location redirect doesn't seem to change
    # the hostname header appropriately, so we do
    # by hand. (Is this a bug in urllib2?)
    new_host = re.match(r'http[s]*://(.*?\.google\.com)',
    headers.getheader('Location'))
    if new_host:
    req.add_header("Host", new_host.groups()[0])
    result = urllib2.HTTPRedirectHandler.http_error_302(
    self, req, fp, code, msg, headers)
    return result
    class CookieJar:
    A rough cookie handler, intended to only refer to one domain.
    Does no expiry or anything like that.
    (The only reason this is here is so I don't have to require
    the `ClientCookie` package.)
    def __init__(self):
    self._cookies = {}
    def extractCookies(self, headers, nameFilter = None):
    # TODO: Do this all more nicely?
    for cookie in headers.getheaders('Set-Cookie'):
    name, value = (cookie.split("=", 1) + [""])[:2]
    if LG_DEBUG: print "Extracted cookie `%s`" % (name)
    if not nameFilter or name in nameFilter:
    self._cookies[name] = value.split(";")[0]
    if LG_DEBUG: print "Stored cookie `%s` value `%s`" % (name, self._cookies[name])
    if self._cookies[name] == "EXPIRED":
    if LG_DEBUG:
    print "We got an expired cookie: %s:%s, deleting." % (name, self._cookies[name])
    del self._cookies[name]
    def addCookie(self, name, value):
    self._cookies[name] = value
    def setCookies(self, request):
    request.add_header('Cookie',
    ";".join(["%s=%s" % (k,v)
    for k,v in self._cookies.items()]))
    def _buildURL(**kwargs):
    return "%s%s" % (URL_GMAIL, urllib.urlencode(kwargs))
    def _paramsToMime(params, filenames, files):
    mimeMsg = MIMEMultipart("form-data")
    for name, value in params.iteritems():
    mimeItem = MIMEText(value)
    mimeItem.add_header("Content-Disposition", "form-data", name=name)
    # TODO: Handle this better...?
    for hdr in ['Content-Type','MIME-Version','Content-Transfer-Encoding']:
    del mimeItem[hdr]
    mimeMsg.attach(mimeItem)
    if filenames or files:
    filenames = filenames or []
    files = files or []
    for idx, item in enumerate(filenames + files):
    # TODO: This is messy, tidy it...
    if isinstance(item, str):
    # We assume it's a file path...
    filename = item
    contentType = mimetypes.guess_type(filename)[0]
    payload = open(filename, "rb").read()
    else:
    # We assume it's an `email.Message.Message` instance...
    # TODO: Make more use of the pre-encoded information?
    filename = item.get_filename()
    contentType = item.get_content_type()
    payload = item.get_payload(decode=True)
    if not contentType:
    contentType = "application/octet-stream"
    mimeItem = MIMEBase(*contentType.split("/"))
    mimeItem.add_header("Content-Disposition", "form-data",
    name="file%s" % idx, filename=filename)
    # TODO: Encode the payload?
    mimeItem.set_payload(payload)
    # TODO: Handle this better...?
    for hdr in ['MIME-Version','Content-Transfer-Encoding']:
    del mimeItem[hdr]
    mimeMsg.attach(mimeItem)
    del mimeMsg['MIME-Version']
    return mimeMsg
    class GmailLoginFailure(Exception):
    Raised whenever the login process fails--could be wrong username/password,
    or Gmail service error, for example.
    Extract the error message like this:
    try:
    foobar
    except GmailLoginFailure,e:
    mesg = e.message# or
    print e# uses the __str__
    def __init__(self,message):
    self.message = message
    def __str__(self):
    return repr(self.message)
    class GmailAccount:
    def __init__(self, name = "", pw = "", state = None, domain = None):
    global URL_LOGIN, URL_GMAIL
    self.domain = domain
    if self.domain:
    URL_LOGIN = "https://www.google.com/a/" + self.domain + "/LoginAction"
    URL_GMAIL = "http://mail.google.com/a/" + self.domain + "/?"
    else:
    URL_LOGIN = GMAIL_URL_LOGIN
    URL_GMAIL = GMAIL_URL_GMAIL
    if name and pw:
    self.name = name
    self._pw = pw
    self._cookieJar = CookieJar()
    if PROXY_URL is not None:
    import gmail_transport
    self.opener = urllib2.build_opener(gmail_transport.ConnectHTTPHandler(proxy = PROXY_URL),
    gmail_transport.ConnectHTTPSHandler(proxy = PROXY_URL),
    SmartRedirectHandler(self._cookieJar))
    else:
    self.opener = urllib2.build_opener(
    urllib2.HTTPHandler(debuglevel=0),
    urllib2.HTTPSHandler(debuglevel=0),
    SmartRedirectHandler(self._cookieJar))
    elif state:
    # TODO: Check for stale state cookies?
    self.name, self._cookieJar = state.state
    else:
    raise ValueError("GmailAccount must be instantiated with " \
    "either GmailSessionState object or name " \
    "and password.")
    self._cachedQuotaInfo = None
    self._cachedLabelNames = None
    def login(self):
    # TODO: Throw exception if we were instantiated with state?
    if self.domain:
    data = urllib.urlencode({'continue': URL_GMAIL,
    'at' : 'null',
    'service' : 'mail',
    'userName': self.name,
    'password': self._pw,
    else:
    data = urllib.urlencode({'continue': URL_GMAIL,
    'Email': self.name,
    'Passwd': self._pw,
    headers = {'Host': 'www.google.com',
    'User-Agent': 'Mozilla/5.0 (Compatible; libgmail-python)'}
    req = urllib2.Request(URL_LOGIN, data=data, headers=headers)
    pageData = self._retrievePage(req)
    if not self.domain:
    # The GV cookie no longer comes in this page for
    # "Apps", so this bottom portion is unnecessary for it.
    # This requests the page that provides the required "GV" cookie.
    RE_PAGE_REDIRECT = 'CheckCookie\?continue=([^"\']+)'
    # TODO: Catch more failure exceptions here...?
    try:
    link = re.search(RE_PAGE_REDIRECT, pageData).group(1)
    redirectURL = urllib2.unquote(link)
    redirectURL = redirectURL.replace('\\x26', '&')
    except AttributeError:
    raise GmailLoginFailure("Login failed. (Wrong username/password?)")
    # We aren't concerned with the actual content of this page,
    # just the cookie that is returned with it.
    pageData = self._retrievePage(redirectURL)
    def _retrievePage(self, urlOrRequest):
    if self.opener is None:
    raise "Cannot find urlopener"
    if not isinstance(urlOrRequest, urllib2.Request):
    req = urllib2.Request(urlOrRequest)
    else:
    req = urlOrRequest
    self._cookieJar.setCookies(req)
    req.add_header('User-Agent',
    'Mozilla/5.0 (Compatible; libgmail-python)')
    try:
    resp = self.opener.open(req)
    except urllib2.HTTPError,info:
    print info
    return None
    pageData = resp.read()
    # Extract cookies here
    self._cookieJar.extractCookies(resp.headers)
    # TODO: Enable logging of page data for debugging purposes?
    return pageData
    def _parsePage(self, urlOrRequest):
    Retrieve & then parse the requested page content.
    items = _parsePage(self._retrievePage(urlOrRequest))
    # Automatically cache some things like quota usage.
    # TODO: Cache more?
    # TODO: Expire cached values?
    # TODO: Do this better.
    try:
    self._cachedQuotaInfo = items[D_QUOTA]
    except KeyError:
    pass
    #pprint.pprint(items)
    try:
    self._cachedLabelNames = [category[CT_NAME] for category in items[D_CATEGORIES][0]]
    except KeyError:
    pass
    return items
    def _parseSearchResult(self, searchType, start = 0, **kwargs):
    params = {U_SEARCH: searchType,
    U_START: start,
    U_VIEW: U_THREADLIST_VIEW,
    params.update(kwargs)
    return self._parsePage(_buildURL(**params))
    def _parseThreadSearch(self, searchType, allPages = False, **kwargs):
    Only works for thread-based results at present. # TODO: Change this?
    start = 0
    tot = 0
    threadsInfo = []
    # Option to get *all* threads if multiple pages are used.
    while (start == 0) or (allPages and
    len(threadsInfo) < threadListSummary[TS_TOTAL]):
    items = self._parseSearchResult(searchType, start, **kwargs)
    #TODO: Handle single & zero result case better? Does this work?
    try:
    threads = items[D_THREAD]
    except KeyError:
    break
    else:
    for th in threads:
    if not type(th[0]) is types.ListType:
    th = [th]
    threadsInfo.append(th)
    # TODO: Check if the total or per-page values have changed?
    threadListSummary = items[D_THREADLIST_SUMMARY][0]
    threadsPerPage = threadListSummary[TS_NUM]
    start += threadsPerPage
    # TODO: Record whether or not we retrieved all pages..?
    return GmailSearchResult(self, (searchType, kwargs), threadsInfo)
    def _retrieveJavascript(self, version = ""):
    Note: `version` seems to be ignored.
    return self._retrievePage(_buildURL(view = U_PAGE_VIEW,
    name = "js",
    ver = version))
    def getMessagesByFolder(self, folderName, allPages = False):
    Folders contain conversation/message threads.
    `folderName` -- As set in Gmail interface.
    Returns a `GmailSearchResult` instance.
    *** TODO: Change all "getMessagesByX" to "getThreadsByX"? ***
    return self._parseThreadSearch(folderName, allPages = allPages)
    def getMessagesByQuery(self, query, allPages = False):
    Returns a `GmailSearchResult` instance.
    return self._parseThreadSearch(U_QUERY_SEARCH, q = query,
    allPages = allPages)
    def getQuotaInfo(self, refresh = False):
    Return MB used, Total MB and percentage used.
    # TODO: Change this to a property.
    if not self._cachedQuotaInfo or refresh:
    # TODO: Handle this better...
    self.getMessagesByFolder(U_INBOX_SEARCH)
    return self._cachedQuotaInfo[0][:3]
    def getLabelNames(self, refresh = False):
    # TODO: Change this to a property?
    if not self._cachedLabelNames or refresh:
    # TODO: Handle this better...
    self.getMessagesByFolder(U_INBOX_SEARCH)
    return self._cachedLabelNames
    def getMessagesByLabel(self, label, allPages = False):
    return self._parseThreadSearch(U_CATEGORY_SEARCH,
    cat=label, allPages = allPages)
    def getRawMessage(self, msgId):
    # U_ORIGINAL_MESSAGE_VIEW seems the only one that returns a page.
    # All the other U_* results in a 404 exception. Stas
    PageView = U_ORIGINAL_MESSAGE_VIEW
    return self._retrievePage(
    _buildURL(view=PageView, th=msgId))
    def getUnreadMessages(self):
    return self._parseThreadSearch(U_QUERY_SEARCH,
    q = "is:" + U_AS_SUBSET_UNREAD)
    def getUnreadMsgCount(self):
    items = self._parseSearchResult(U_QUERY_SEARCH,
    q = "is:" + U_AS_SUBSET_UNREAD)
    try:
    result = items[D_THREADLIST_SUMMARY][0][TS_TOTAL_MSGS]
    except KeyError:
    result = 0
    return result
    def _getActionToken(self):
    try:
    at = self._cookieJar._cookies[ACTION_TOKEN_COOKIE]
    except KeyError:
    self.getLabelNames(True)
    at = self._cookieJar._cookies[ACTION_TOKEN_COOKIE]
    return at
    def sendMessage(self, msg, asDraft = False, _extraParams = None):
    `msg` -- `GmailComposedMessage` instance.
    `_extraParams` -- Dictionary containing additional parameters
    to put into POST message. (Not officially
    for external use, more to make feature
    additional a little easier to play with.)
    Note: Now returns `GmailMessageStub` instance with populated
    `id` (and `_account`) fields on success or None on failure.
    # TODO: Handle drafts separately?
    params = {U_VIEW: [U_SENDMAIL_VIEW, U_SAVEDRAFT_VIEW][asDraft],
    U_REFERENCED_MSG: "",
    U_THREAD: "",
    U_DRAFT_MSG: "",
    U_COMPOSEID: "1",
    U_ACTION_TOKEN: self._getActionToken(),
    U_COMPOSE_TO: msg.to,
    U_COMPOSE_CC: msg.cc,
    U_COMPOSE_BCC: msg.bcc,
    "subject": msg.subject,
    "msgbody": msg.body,
    if _extraParams:
    params.update(_extraParams)
    # Amongst other things, I used the following post to work out this:
    # <http://groups.google.com/groups?
    # selm=mailman.1047080233.20095.python-list%40python.org>
    mimeMessage = _paramsToMime(params, msg.filenames, msg.files)
    #### TODO: Ughh, tidy all this up & do it better...
    ## This horrible mess is here for two main reasons:
    ## 1. The `Content-Type` header (which also contains the boundary
    ## marker) needs to be extracted from the MIME message so
    ## we can send it as the request `Content-Type` header instead.
    ## 2. It seems the form submission needs to use "\r\n" for new
    ## lines instead of the "\n" returned by `as_string()`.
    ## I tried changing the value of `NL` used by the `Generator` class
    ## but it didn't work so I'm doing it this way until I figure
    ## out how to do it properly. Of course, first try, if the payloads
    ## contained "\n" sequences they got replaced too, which corrupted
    ## the attachments. I could probably encode the submission,
    ## which would probably be nicer, but in the meantime I'm kludging
    ## this workaround that replaces all non-text payloads with a
    ## marker, changes all "\n" to "\r\n" and finally replaces the
    ## markers with the original payloads.
    ## Yeah, I know, it's horrible, but hey it works doesn't it? If you've
    ## got a problem with it, fix it yourself & give me the patch!
    origPayloads = {}
    FMT_MARKER = "&&&&&&%s&&&&&&"
    for i, m in enumerate(mimeMessage.get_payload()):
    if not isinstance(m, MIMEText): #Do we care if we change text ones?
    origPayloads[i] = m.get_payload()
    m.set_payload(FMT_MARKER % i)
    mimeMessage.epilogue = ""
    msgStr = mimeMessage.as_string()
    contentTypeHeader, data = msgStr.split("\n\n", 1)
    contentTypeHeader = contentTypeHeader.split(":", 1)
    data = data.replace("\n", "\r\n")
    for k,v in origPayloads.iteritems():
    data = data.replace(FMT_MARKER % k, v)
    req = urllib2.Request(_buildURL(), data = data)
    req.add_header(*contentTypeHeader)
    items = self._parsePage(req)
    # TODO: Check composeid?
    # Sometimes we get the success message
    # but the id is 0 and no message is sent
    result = None
    resultInfo = items[D_SENDMAIL_RESULT][0]
    if resultInfo[SM_SUCCESS]:
    result = GmailMessageStub(id = resultInfo[SM_NEWTHREADID],
    _account = self)
    else:
    raise GmailSendError, resultInfo[SM_MSG]
    return result
    def trashMessage(self, msg):
    # TODO: Decide if we should make this a method of `GmailMessage`.
    # TODO: Should we check we have been given a `GmailMessage` instance?
    params = {
    U_ACTION: U_DELETEMESSAGE_ACTION,
    U_ACTION_MESSAGE: msg.id,
    U_ACTION_TOKEN: self._getActionToken(),
    items = self._parsePage(_buildURL(**params))
    # TODO: Mark as trashed on success?
    return (items[D_ACTION_RESULT][0][AR_SUCCESS] == 1)
    def _doThreadAction(self, actionId, thread):
    # TODO: Decide if we should make this a method of `GmailThread`.
    # TODO: Should we check we have been given a `GmailThread` instance?
    params = {
    U_SEARCH: U_ALL_SEARCH, #TODO:Check this search value always works.
    U_VIEW: U_UPDATE_VIEW,
    U_ACTION: actionId,
    U_ACTION_THREAD: thread.id,
    U_ACTION_TOKEN: self._getActionToken(),
    items = self._parsePage(_buildURL(**params))
    return (items[D_ACTION_RESULT][0][AR_SUCCESS] == 1)
    def trashThread(self, thread):
    # TODO: Decide if we should make this a method of `GmailThread`.
    # TODO: Should we check we have been given a `GmailThread` instance?
    result = self._doThreadAction(U_MARKTRASH_ACTION, thread)
    # TODO: Mark as trashed on success?
    return result
    def _createUpdateRequest(self, actionId): #extraData):
    Helper method to create a Request instance for an update (view)
    action.
    Returns populated `Request` instance.
    params = {
    U_VIEW: U_UPDATE_VIEW,
    data = {
    U_ACTION: actionId,
    U_ACTION_TOKEN: self._getActionToken(),
    #data.update(extraData)
    req = urllib2.Request(_buildURL(**params),
    data = urllib.urlencode(data))
    return req
    # TODO: Extract additional common code from handling of labels?
    def createLabel(self, labelName):
    req = self._createUpdateRequest(U_CREATECATEGORY_ACTION + labelName)
    # Note: Label name cache is updated by this call as well. (Handy!)
    items = self._parsePage(req)
    print items
    return (items[D_ACTION_RESULT][0][AR_SUCCESS] == 1)
    def deleteLabel(self, labelName):
    # TODO: Check labelName exits?
    req = self._createUpdateRequest(U_DELETECATEGORY_ACTION + labelName)
    # Note: Label name cache is updated by this call as well. (Handy!)
    items = self._parsePage(req)
    return (items[D_ACTION_RESULT][0][AR_SUCCESS] == 1)
    def renameLabel(self, oldLabelName, newLabelName):
    # TODO: Check oldLabelName exits?
    req = self._createUpdateRequest("%s%s^%s" % (U_RENAMECATEGORY_ACTION,
    oldLabelName, newLabelName))
    # Note: Label name cache is updated by this call as well. (Handy!)
    items = self._parsePage(req)
    return (items[D_ACTION_RESULT][0][AR_SUCCESS] == 1)
    def storeFile(self, filename, label = None):
    # TODO: Handle files larger than single attachment size.
    # TODO: Allow file data objects to be supplied?
    FILE_STORE_VERSION = "FSV_01"
    FILE_STORE_SUBJECT_TEMPLATE = "%s %s" % (FILE_STORE_VERSION, "%s")
    subject = FILE_STORE_SUBJECT_TEMPLATE % os.path.basename(filename)
    msg = GmailComposedMessage(to="", subject=subject, body="",
    filenames=[filename])
    draftMsg = self.sendMessage(msg, asDraft = True)
    if draftMsg and label:
    draftMsg.addLabel(label)
    return draftMsg
    ## CONTACTS SUPPORT
    def getContacts(self):
    Returns a GmailContactList object
    that has all the contacts in it as
    GmailContacts
    contactList = []
    # pnl = a is necessary to get *all* contacts
    myUrl = _buildURL(view='cl',search='contacts', pnl='a')
    myData = self._parsePage(myUrl)
    # This comes back with a dictionary
    # with entry 'cl'
    addresses = myData['cl']
    for entry in addresses:
    if len(entry) >= 6 and entry[0]=='ce':
    newGmailContact = GmailContact(entry[1], entry[2], entry[4], entry[5])
    #### new code used to get all the notes
    #### not used yet due to lockdown problems
    ##rawnotes = self._getSpecInfo(entry[1])
    ##print rawnotes
    ##newGmailContact = GmailContact(entry[1], entry[2], entry[4],rawnotes)
    contactList.append(newGmailContact)
    return GmailContactList(contactList)
    def addContact(self, myContact, *extra_args):
    Attempts to add a GmailContact to the gmail
    address book. Returns true if successful,
    false otherwise
    Please note that after version 0.1.3.3,
    addContact takes one argument of type
    GmailContact, the contact to add.
    The old signature of:
    addContact(name, email, notes='') is still
    supported, but deprecated.
    if len(extra_args) > 0:
    # The user has passed in extra arguments
    # He/she is probably trying to invoke addContact
    # using the old, deprecated signature of:
    # addContact(self, name, email, notes='')
    # Build a GmailContact object and use that instead
    (name, email) = (myContact, extra_args[0])
    if len(extra_args) > 1:
    notes = extra_args[1]
    else:
    notes = ''
    myContact = GmailContact(-1, name, email, notes)
    # TODO: In the ideal world, we'd extract these specific
    # constants into a nice constants file
    # This mostly comes from the Johnvey Gmail API,
    # but also from the gmail.py cited earlier
    myURL = _buildURL(view='up')
    myDataList = [ ('act','ec'),
    ('at', self._cookieJar._cookies['GMAIL_AT']), # Cookie data?
    ('ct_nm', myContact.getName()),
    ('ct_em', myContact.getEmail()),
    ('ct_id', -1 )
    notes = myContact.getNotes()
    if notes != '':
    myDataList.append( ('ctf_n', notes) )
    validinfokeys = [
    'i', # IM
    'p', # Phone
    'd', # Company
    'a', # ADR
    'e', # Email
    'm', # Mobile
    'b', # Pager
    'f', # Fax
    't', # Title
    'o', # Other
    moreInfo = myContact.getMoreInfo()
    ctsn_num = -1
    if moreInfo != {}:
    for ctsf,ctsf_data in moreInfo.items():
    ctsn_num += 1
    # data section header, WORK, HOME,...
    sectionenum ='ctsn_%02d' % ctsn_num
    myDataList.append( ( sectionenum, ctsf ))
    ctsf_num = -1
    if isinstance(ctsf_data[0],str):
    ctsf_num += 1
    # data section
    subsectionenum = 'ctsf_%02d_%02d_%s' % (ctsn_num, ctsf_num, ctsf_data[0]) # ie. ctsf_00_01_p
    myDataList.append( (subsectionenum, ctsf_data[1]) )
    else:
    for info in ctsf_data:
    if validinfokeys.count(info[0]) > 0:
    ctsf_num += 1
    # data section
    subsectionenum = 'ctsf_%02d_%02d_%s' % (ctsn_num, ctsf_num, info[0]) # ie. ctsf_00_01_p
    myDataList.append( (subsectionenum, info[1]) )
    myData = urllib.urlencode(myDataList)
    request = urllib2.Request(myURL,
    data = myData)
    pageData = self._retrievePage(request)
    if pageData.find("The contact was successfully added") == -1:
    print pageData
    if pageData.find("already has the email address") > 0:
    raise Exception("Someone with same email already exists in Gmail.")
    elif pageData.find("https://www.google.com/accounts/ServiceLogin"):
    raise Exception("Login has expired.")
    return False
    else:
    return True
    def _removeContactById(self, id):
    Attempts to remove the contact that occupies
    id "id" from the gmail address book.
    Returns True if successful,
    False otherwise.
    This is a little dangerous since you don't really
    know who you're deleting. Really,
    this should return the name or something of the
    person we just killed.
    Don't call this method.
    You should be using removeContact instead.
    myURL = _buildURL(search='contacts', ct_id = id, c=id, act='dc', at=self._cookieJar._cookies['GMAIL_AT'], view='up')
    pageData = self._retrievePage(myURL)
    if pageData.find("The contact has been deleted") == -1:
    return False
    else:
    return True
    def removeContact(self, gmailContact):
    Attempts to remove the GmailContact passed in
    Returns True if successful, False otherwise.
    # Let's re-fetch the contact list to make
    # sure we're really deleting the guy
    # we think we're deleting
    newContactList = self.getContacts()
    newVersionOfPersonToDelete = newContactList.getContactById(gmailContact.getId())
    # Ok, now we need to ensure that gmailContact
    # is the same as newVersionOfPersonToDelete
    # and then we can go ahead and delete him/her
    if (gmailContact == newVersionOfPersonToDelete):
    return self._removeContactById(gmailContact.getId())
    else:
    # We have a cache coherency problem -- someone
    # else now occupies this ID slot.
    # TODO: Perhaps signal this in some nice way
    # to the end user?
    print "Unable to delete."
    print "Has someone else been modifying the contacts list while we have?"
    print "Old version of person:",gmailContact
    print "New version of person:",newVersionOfPersonToDelete
    return False
    ## Don't remove this. contact stas
    ## def _getSpecInfo(self,id):
    ## Return all the notes data.
    ## This is currently not used due to the fact that it requests pages in
    ## a dos attack manner.
    ## myURL =_buildURL(search='contacts',ct_id=id,c=id,\
    ## at=self._cookieJar._cookies['GMAIL_AT'],view='ct')
    ## pageData = self._retrievePage(myURL)
    ## myData = self._parsePage(myURL)
    ## #print "\nmyData form _getSpecInfo\n",myData
    ## rawnotes = myData['cov'][7]
    ## return rawnotes
    class GmailContact:
    Class for storing a Gmail Contacts list entry
    def __init__(self, name, email, *extra_args):
    Returns a new GmailContact object
    (you can then call addContact on this to commit
    it to the Gmail addressbook, for example)
    Consider calling setNotes() and setMoreInfo()
    to add extended information to this contact
    # Support populating other fields if we're trying
    # to invoke this the old way, with the old constructor
    # whose signature was __init__(self, id, name, email, notes='')
    id = -1
    notes = ''
    if len(extra_args) > 0:
    (id, name) = (name, email)
    email = extra_args[0]
    if len(extra_args) > 1:
    notes = extra_args[1]
    else:
    notes = ''
    self.id = id
    self.name = name
    self.email = email
    self.notes = notes
    self.moreInfo = {}
    def __str__(self):
    return "%s %s %s %s" % (self.id, self.name, self.email, self.notes)
    def __eq__(self, other):
    if not isinstance(other, GmailContact):
    return False
    return (self.getId() == other.getId()) and \
    (self.getName() == other.getName()) and \
    (self.getEmail() == other.getEmail()) and \
    (self.getNotes() == other.getNotes())
    def getId(self):
    return self.id
    def getName(self):
    return self.name
    def getEmail(self):
    return self.email
    def getNotes(self):
    return self.notes
    def setNotes(self, notes):
    Sets the notes field for this GmailContact
    Note that this does NOT change the note
    field on Gmail's end; only adding or removing
    contacts modifies them
    self.notes = notes
    def getMoreInfo(self):
    return self.moreInfo
    def setMoreInfo(self, moreInfo):
    moreInfo format
    Use special key values::
    'i' = IM
    'p' = Phone
    'd' = Company
    'a' = ADR
    'e' = Email
    'm' = Mobile
    'b' = Pager
    'f' = Fax
    't' = Title
    'o' = Other
    Simple example::
    moreInfo = {'Home': ( ('a','852 W Barry'),
    ('p', '1-773-244-1980'),
    ('i', 'aim:brianray34') ) }
    Complex example::
    moreInfo = {
    'Personal': (('e', 'Home Email'),
    ('f', 'Home Fax')),
    'Work': (('d', 'Sample Company'),
    ('t', 'Job Title'),
    ('o', 'Department: Department1'),
    ('o', 'Department: Department2'),
    ('p', 'Work Phone'),
    ('m', 'Mobile Phone'),
    ('f', 'Work Fax'),
    ('b', 'Pager')) }
    self.moreInfo = moreInfo
    def getVCard(self):
    """Returns a vCard 3.0 for this
    contact, as a string"""
    # The \r is is to comply with the RFC2425 section 5.8.1
    vcard = "BEGIN:VCARD\r\n"
    vcard += "VERSION:3.0\r\n"
    ## Deal with multiline notes
    ##vcard += "NOTE:%s\n" % self.getNotes().replace("\n","\\n")
    vcard += "NOTE:%s\r\n" % self.getNotes()
    # Fake-out N by splitting up whatever we get out of getName
    # This might not always do 'the right thing'
    # but it's a *reasonable* compromise
    fullname = self.getName().split()
    fullname.reverse()
    vcard += "N:%s" % ';'.join(fullname) + "\r\n"
    vcard += "FN:%s\r\n" % self.getName()
    vcard += "EMAIL;TYPE=INTERNET:%s\r\n" % self.getEmail()
    vcard += "END:VCARD\r\n\r\n"
    # Final newline in case we want to put more than one in a file
    return vcard
    class GmailContactList:
    Class for storing an entire Gmail contacts list
    and retrieving contacts by Id, Email address, and name
    def __init__(self, contactList):
    self.contactList = contactList
    def __str__(self):
    return '\n'.join([str(item) for item in self.contactList])
    def getCount(self):
    Returns number of contacts
    return len(self.contactList)
    def getAllContacts(self):
    Returns an array of all the
    GmailContacts
    return self.contactList
    def getContactByName(self, name):
    Gets the first contact in the
    address book whose name is 'name'.
    Returns False if no contact
    could be found
    nameList = self.getContactListByName(name)
    if len(nameList) > 0:
    return nameList[0]
    else:
    return False
    def getContactByEmail(self, email):
    Gets the first contact in the
    address book whose name is 'email'.
    As of this writing, Gmail insists
    upon a unique email; i.e. two contacts
    cannot share an email address.
    Returns False if no contact
    could be found
    emailList = self.getContactListByEmail(email)
    if len(emailList) > 0:
    return emailList[0]
    else:
    return False
    def getContactById(self, myId):
    Gets the first contact in the
    address book whose id is 'myId'.
    REMEMBER: ID IS A STRING
    Returns False if no contact
    could be found
    idList = self.getContactListById(myId)
    if len(idList) > 0:
    return idList[0]
    else:
    return False
    def getContactListByName(self, name):
    This function returns a LIST
    of GmailContacts whose name is
    'name'.
    Returns an empty list if no contacts
    were found
    nameList = []
    for entry in self.contactList:
    if entry.getName() == name:
    nameList.append(entry)
    return nameList
    def getContactListByEmail(self, email):
    This function returns a LIST
    of GmailContacts whose email is
    'email'. As of this writing, two contacts
    cannot share an email address, so this
    should only return just one item.
    But it doesn't hurt to be prepared?
    Returns an empty list if no contacts
    were found
    emailList = []
    for entry in self.contactList:
    if entry.getEmail() == email:
    emailList.append(entry)
    return emailList
    def getContactListById(self, myId):
    This function returns a LIST
    of GmailContacts whose id is
    'myId'. We expect there only to
    be one, but just in case!
    Remember: ID IS A STRING
    Returns an empty list if no contacts
    were found
    idList = []
    for entry in self.contactList:
    if entry.getId() == myId:
    idList.append(entry)
    return idList
    def search(self, searchTerm):
    This function returns a LIST
    of GmailContacts whose name or
    email address matches the 'searchTerm'.
    Returns an empty list if no matches
    were found.
    searchResults = []
    for entry in self.contactList:
    p = re.compile(searchTerm, re.IGNORECASE)
    if p.search(entry.getName()) or p.search(entry.getEmail()):
    searchResults.append(entry)
    return searchResults
    class GmailSearchResult:
    def __init__(self, account, search, threadsInfo):
    `threadsInfo` -- As returned from Gmail but unbunched.
    #print "\nthreadsInfo\n",threadsInfo
    try:
    if not type(threadsInfo[0]) is types.ListType:
    threadsInfo = [threadsInfo]
    except IndexError:
    print "No messages found"
    self._account = account
    self.search = search # TODO: Turn into object + format nicely.
    self._threads = []
    for thread in threadsInfo:
    self._threads.append(GmailThread(self, thread[0]))
    def __iter__(self):
    return iter(self._threads)
    def __len__(self):
    return len(self._threads)
    def __getitem__(self,key):
    return self._threads.__getitem__(key)
    class GmailSessionState:
    def __init__(self, account = None, filename = ""):
    if account:
    self.state = (account.name, account._cookieJar)
    elif filename:
    self.state = load(open(filename, "rb"))
    else:
    raise ValueError("GmailSessionState must be instantiated with " \
    "either GmailAccount object or filename.")
    def save(self, filename):
    dump(self.state, open(filename, "wb"), -1)
    class _LabelHandlerMixin(object):
    Note: Because a message id can be used as a thread id this works for
    messages as well as threads.
    def __init__(self):
    self._labels = None
    def _makeLabelList(self, labelList):
    self._labels = labelList
    def addLabel(self, labelName):
    # Note: It appears this also automatically creates new labels.
    result = self._account._doThreadAction(U_ADDCATEGORY_ACTION+labelName,
    self)
    if not self._labels:
    self._makeLabelList([])
    # TODO: Caching this seems a little dangerous; suppress duplicates maybe?
    self._labels.append(labelName)
    return result
    def removeLabel(self, labelName):
    # TODO: Check label is already attached?
    # Note: An error is not generated if the label is not already attached.
    result = \
    self._account._doThreadAction(U_REMOVECATEGORY_ACTION+labelName,
    self)
    removeLabel = True
    try:
    self._labels.remove(labelName)
    except:
    removeLabel = False
    pass
    # If we don't check both, we might end up in some weird inconsistent state
    return result and removeLabel
    def getLabels(self):
    return self._labels
    class GmailThread(_LabelHandlerMixin):
    Note: As far as I can tell, the "canonical" thread id is always the same
    as the id of the last message in the thread. But it appears that
    the id of any message in the thread can be used to retrieve
    the thread information.
    def __init__(self, parent, threadsInfo):
    _LabelHandlerMixin.__init__(self)
    # TODO Handle this better?
    self._parent = parent
    self._account = self._parent._account
    self.id = threadsInfo[T_THREADID] # TODO: Change when canonical updated?
    self.subject = threadsInfo[T_SUBJECT_HTML]
    self.snippet = threadsInfo[T_SNIPPET_HTML]
    #self.extraSummary = threadInfo[T_EXTRA_SNIPPET] #TODO: What is this?
    # TODO: Store other info?
    # Extract number of messages in thread/conversation.
    self._authors = threadsInfo[T_AUTHORS_HTML]
    self.info = threadsInfo
    try:
    # TODO: Find out if this information can be found another way...
    # (Without another page request.)
    self._length = int(re.search("\((\d+?)\)\Z",
    self._authors).group(1))
    except AttributeError,info:
    # If there's no message count then the thread only has one message.
    self._length = 1
    # TODO: Store information known about the last message (e.g. id)?
    self._messages = []
    # Populate labels
    self._makeLabelList(threadsInfo[T_CATEGORIES])
    def __getattr__(self, name):
    Dynamically dispatch some interesting thread properties.
    attrs = { 'unread': T_UNREAD,
    'star': T_STAR,
    'date': T_DATE_HTML,
    'authors': T_AUTHORS_HTML,
    'flags': T_FLAGS,
    'subject': T_SUBJECT_HTML,
    'snippet': T_SNIPPET_HTML,
    'categories': T_CATEGORIES,
    'attach': T_ATTACH_HTML,
    'matching_msgid': T_MATCHING_MSGID,
    'extra_snippet': T_EXTRA_SNIPPET }
    if name in attrs:
    return self.info[ attrs[name] ];
    raise AttributeError("no attribute %s" % name)
    def __len__(self):
    return self._length
    def __iter__(self):
    if not self._messages:
    self._messages = self._getMessages(self)
    return iter(self._messages)
    def __getitem__(self, key):
    if not self._messages:
    self._messages = self._getMessages(self)
    try:
    result = self._messages.__getitem__(key)
    except IndexError:
    result = []
    return result
    def _getMessages(self, thread):
    # TODO: Do this better.
    # TODO: Specify the query folder using our specific search?
    items = self._account._parseSearchResult(U_QUERY_SEARCH,
    view = U_CONVERSATION_VIEW,
    th = thread.id,
    q = "in:anywhere")
    result = []
    # TODO: Handle this better?
    # Note: This handles both draft & non-draft messages in a thread...
    for key, isDraft in [(D_MSGINFO, False), (D_DRAFTINFO, True)]:
    try:
    msgsInfo = items[key]
    except KeyError:
    # No messages of this type (e.g. draft or non-draft)
    continue
    else:
    # TODO: Handle special case of only 1 message in thread better?
    if type(msgsInfo[0]) != types.ListType:
    msgsInfo = [msgsInfo]
    for msg in msgsInfo:
    result += [GmailMessage(thread, msg, isDraft = isDraft)]
    return result
    class GmailMessageStub(_LabelHandlerMixin):
    Intended to be used where not all message information is known/required.
    NOTE: This may go away.
    # TODO: Provide way to convert this to a full `GmailMessage` instance
    # or allow `GmailMessage` to be created without all info?
    def __init__(self, id = None, _account = None):
    _LabelHandlerMixin.__init__(self)
    self.id = id
    self._account = _account
    class GmailMessage(object):
    def __init__(self, parent, msgData, isDraft = False):
    Note: `msgData` can be from either D_MSGINFO or D_DRAFTINFO.
    # TODO: Automatically detect if it's a draft or not?
    # TODO Handle this better?
    self._parent = parent
    self._account = self._parent._account
    self.author = msgData[MI_AUTHORFIRSTNAME]
    self.id = msgData[MI_MSGID]
    self.number = msgData[MI_NUM]
    self.subject = msgData[MI_SUBJECT]
    self.to = msgData[MI_TO]
    self.cc = msgData[MI_CC]
    self.bcc = msgData[MI_BCC]
    self.sender = msgData[MI_AUTHOREMAIL]
    self.attachments = [GmailAttachment(self, attachmentInfo)
    for attachmentInfo in msgData[MI_ATTACHINFO]]
    # TODO: Populate additional fields & cache...(?)
    # TODO: Handle body differently if it's from a draft?
    self.isDraft = isDraft
    self._source = None
    def _getSource(self):
    if not self._source:
    # TODO: Do this more nicely...?
    # TODO: Strip initial white space & fix up last line ending
    # to make it legal as per RFC?
    self._source = self._account.getRawMessage(self.id)
    return self._source
    source = property(_getSource, doc = "")
    class GmailAttachment:
    def __init__(self, parent, attachmentInfo):
    # TODO Handle this better?
    self._parent = parent
    self._account = self._parent._account
    self.id = attachmentInfo[A_ID]
    self.filename = attachmentInfo[A_FILENAME]
    self.mimetype = attachmentInfo[A_MIMETYPE]
    self.filesize = attachmentInfo[A_FILESIZE]
    self._content = None
    def _getContent(self):
    if not self._content:
    # TODO: Do this a more nicely...?
    self._content = self._account._retrievePage(
    _buildURL(view=U_ATTACHMENT_VIEW, disp="attd",
    attid=self.id, th=self._parent._parent.id))
    return self._content
    content = property(_getContent, doc = "")
    def _getFullId(self):
    Returns the "full path"/"full id" of the attachment. (Used
    to refer to the file when forwarding.)
    The id is of the form: "<thread_id>_<msg_id>_<attachment_id>"
    return "%s_%s_%s" % (self._parent._parent.id,
    self._parent.id,
    self.id)
    _fullId = property(_getFullId, doc = "")
    class GmailComposedMessage:
    def __init__(self, to, subject, body, cc = None, bcc = None,
    filenames = None, files = None):
    `filenames` - list of the file paths of the files to attach.
    `files` - list of objects implementing sub-set of
    `email.Message.Message` interface (`get_filename`,
    `get_content_type`, `get_payload`). This is to
    allow use of payloads from Message instances.
    TODO: Change this to be simpler class we define ourselves?
    self.to = to
    self.subject = subject
    self.body = body
    self.cc = cc
    self.bcc = bcc
    self.filenames = filenames
    self.files = files
    if __name__ == "__main__":
    import sys
    from getpass import getpass
    try:
    name = sys.argv[1]
    except IndexError:
    name = raw_input("Gmail account name: ")
    pw = getpass("Password: ")
    domain = raw_input("Domain? [leave blank for Gmail]: ")
    ga = GmailAccount(name, pw, domain=domain)
    print "\nPlease wait, logging in..."
    try:
    ga.login()
    except GmailLoginFailure,e:
    print "\nLogin failed. (%s)" % e.message
    else:
    print "Login successful.\n"
    # TODO: Use properties instead?
    quotaInfo = ga.getQuotaInfo()
    quotaMbUsed = quotaInfo[QU_SPACEUSED]
    quotaMbTotal = quotaInfo[QU_QUOTA]
    quotaPercent = quotaInfo[QU_PERCENT]
    print "%s of %s used. (%s)\n" % (quotaMbUsed, quotaMbTotal, quotaPercent)
    searches = STANDARD_FOLDERS + ga.getLabelNames()
    name = None
    while 1:
    try:
    print "Select folder or label to list: (Ctrl-C to exit)"
    for optionId, optionName in enumerate(searches):
    print " %d. %s" % (optionId, optionName)
    while not name:
    try:
    name = searches[int(raw_input("Choice: "))]
    except ValueError,info:
    print info
    name = None
    if name in STANDARD_FOLDERS:
    result = ga.getMessagesByFolder(name, True)
    else:
    result = ga.getMessagesByLabel(name, True)
    if not len(result):
    print "No threads found in `%s`." % name
    break
    name = None
    tot = len(result)
    i = 0
    for thread in result:
    print "%s messages in thread" % len(thread)
    print thread.id, len(thread), thread.subject
    for msg in thread:
    print "\n ", msg.id, msg.number, msg.author,msg.subject
    # Just as an example of other usefull things
    #print " ", msg.cc, msg.bcc,msg.sender
    i += 1
    print
    print "number of threads:",tot
    print "number of messages:",i
    except KeyboardInterrupt:
    break
    print "\n\nDone."
    Last edited by Reasons (2008-03-20 01:18:27)

    Thought it might help to give lines 369-relevant of the libgmail so it's easier to read
    def _retrievePage(self, urlOrRequest):
    if self.opener is None:
    raise "Cannot find urlopener"
    if not isinstance(urlOrRequest, urllib2.Request):
    req = urllib2.Request(urlOrRequest)
    else:
    req = urlOrRequest
    self._cookieJar.setCookies(req)
    req.add_header('User-Agent',
    'Mozilla/5.0 (Compatible; libgmail-python)')
    try:
    resp = self.opener.open(req)
    except urllib2.HTTPError,info:
    print info
    return None
    pageData = resp.read()
    # Extract cookies here
    self._cookieJar.extractCookies(resp.headers)
    # TODO: Enable logging of page data for debugging purposes?
    return pageData
    def _parsePage(self, urlOrRequest):
    Retrieve & then parse the requested page content.
    items = _parsePage(self._retrievePage(urlOrRequest))
    # Automatically cache some things like quota usage.
    # TODO: Cache more?
    # TODO: Expire cached values?
    # TODO: Do this better.
    try:
    self._cachedQuotaInfo = items[D_QUOTA]
    except KeyError:
    pass
    #pprint.pprint(items)
    try:
    self._cachedLabelNames = [category[CT_NAME] for category in items[D_CATEGORIES][0]]
    except KeyError:
    pass
    return items
    def _parseSearchResult(self, searchType, start = 0, **kwargs):
    params = {U_SEARCH: searchType,
    U_START: start,
    U_VIEW: U_THREADLIST_VIEW,
    params.update(kwargs)
    return self._parsePage(_buildURL(**params))

  • How can I get rid of a music file use in a menu?

    How can I get rid of a music file use in a menu? I try to get rid of it from the menu inspector but although I delete it there, it is still in use by the menu!
    it is not inthe audio window in the menu inspector but is still in use! wiered!

    Click on the menu with the audio, then look in the property inspector, under the 'general' tab.
    Towards the bottom there is the list containing the audio file for the menu - click on the file and use the '-' button in the bottom left corner of the PI...

  • Music in the background of menu

    I'm trying to add music to the background of the initial menu for an iDVD project but I'm having no luck. Does anyone know how I can accomplish this? I've trid dragging the files from itunes to the menu area and it just doesn't work even though it do show the music link in the menu info.

    Never mind. I figured it out. The file I was working with I guess got corrupt. So I started over again with a new fresh theme and imported the audio first then the videos and it works now.

  • In iDVD unable to add different music from iTunes to Motion menu inspector

    In iDVD unable to add different music from iTunes to Motion menu inspector

    What version of iDVD are you using?  What happens when you try to drag a track from the Media Browser into the audio bin for the menu?  What theme are you using?
    OT

  • Application wide popup menu for JTextComponent descendants

    Hi!
    I'm working on large project with reach Swing GUI and I got stuck with one small but wery annoing problem. I have to append simple popup menu to all text input fields (JTextComponent descendants) in whole application. I'm realy lazy to append mouse listener on each component, so I'm asking, is there any way to append "default" popup menu for all components. Please, don't answer about custom components instead of Swing plain JTextComponent descendants - it's worse to change classes for all fields then add mouse listener to them.
    As an example of what I want I could forward you to UIManager.put() method, which affects all properties of component behaviour thoughout application. I want to find same solution, maybe there any registry or smth. else in API.
    Than you in advice.

    You could always try extending something like MetalTextFieldUI so that it adds the listeners to the text field automatically. You'd then need to register that UI class with the UIManager at startup:
    public class MyTextFieldUI extends MetalTextFieldUI {
      protected void installListeners() {
        super.installListeners();
        // TODO - Install your listener here
      protected void uninstallListeners() {
        super.uninstallListeners();
        // TODO - Uninstall your listener here
    UIManager.put("TextFieldUI", MyTextFieldUI.class.getName());Personally, I think you're just being lazy... getting your components to extend a subclass of JTextField should be no trouble at all and will leave you with clearer code.
    Hope this helps.

  • You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You changed the order of the menu for "Open in a new window" or "Open in new Tab", How can I change it back? Or how can I omit any reference to tabs? I do not use them at all.

    You can use the Menu Editor add-on to rearrange or remove menu items - https://addons.mozilla.org/firefox/addon/menu-editor

  • HT201272 Before backing up my old iphone4 I traded it in for an iphone5. All of the apps I purchased I had no problem retrieving from itunes with no charge but I can't download music that I have already paid for that was not backed up w/out paying again.

    Before backing up my old iphone4 I traded it in for an iphone5. All of the apps I purchased had no problem downloading to my new phone from itunes with no charge, but I can't download music that I have already paid for that was not backed up w/out paying again. How can I get these songs to my new phone without having to buy them again?

    Whether you can re-download music depends upon what country that you are in (and whether it remains in the store). If you don't have a Music section in the Purchased tab in the iTunes store app on your phone for re-downloading it, then do you not have you library on your computer's iTunes or on your backup of your downloads ? If not then you could try contacting iTunes Support and see if they will grant you a re-download

  • How can i create a drop down menu for set qty in my store?

    I'm wondering how i can create a drop down menu for the qty module that sits on the individual product page. My client sells in quantities of 6 packs. I currently have the minimum order at 6 but i would like to give consumers the option for 6,12,18...and so forth. I was told that it could be accomplished? Hopefully someone can help me.

    Hi Chris -
    Thank you for your reply! I had seen your article before, and just now again attempted to follow it, but I get stuck. There are two things that I'm confused by.
    First off, toward the top, referring to the initial button, you say to add this interaction:
    ON CLICK; Play Transition to comboBox: selected
    ON ROLL OUT; Play Transition to comboBox normal if comboBox is in over state
    ON ROLL OVER; Play Transition to comboBox over if comboBox is in normal
    However, I do not see these transition options. When I select the button, the only interactions I have are to Play transistion to state, Play action sequence, Go to URL, and two for videos. So that's the first roadblock for me.
    But, trying to get passed that, I went down to the portion of the article that refers to adding interaction to the dataset items. Again, I don't get it, as I see no way to add interaction to a dataset item. When I open my design-time data menu, I do see the items, and am able to rename each item, add additional rows, and change the shape of the datalist layout. However, I see no way to add an interaction to a dataset item. I must be missing a step ... Can you help with this?
    Again, thank you!
    Amy

  • Is there a way to create a vertical menu for tablet that stays in place?

    I am a novice in web design, and I want to make a vertical menu for a tablet page that stays in place.
    It should not scroll, and  it has to resize depending on screen size, so it looks the same across different tablet sizes.
    Is this possible in Muse? After reading some posts I am getting the feeling this is not possible at all, is that really true?
    If it can't be done in Muse, can I do it another  way? In Dreamweaver for instance?
    The reason I want this is that in my opinion horizontal menu's for tablets are ergonomically bad design, and just plain annoying. You always have to use two hands, lift one hand and then you probably block the view of the screen.
    Vertical menu's for tablets just make more sense since they can be made so that you could place them on the side of the screen so it would be possible to navigate with the hand that is holding that side of the tablet.
    I hope someone can help me.

    Yes, I am using the widget.
    It seems it is not possible to make the menu stick in tablet design (the pin options are greyed out). Nor is it possible to make the menu scale with screen sizes.
    A possible solution would be the ability to make it stretch to 100% screen size, like you can with horizontal objects.
    I have noticed though, that, for some reason, in web design it is discouraged or very hard to make things stretch 100% vertically. It seems to cause problems, and I don't understand why.
    Since I have started in web design, I have seen many posts of people having design problems, where stretching 100% vertically would be the obvious solution.

  • I could no longer find hotspot menu for sharing my cellular data on IOS 8.1.3. Please help!

    i have just upgraded to IOS 8.1.3 from IOS 7.1.2 , and I could no longer find my hotspot menu for sharing my cellular data with my other devices.
    what should I do?

    Hello rotimifelix,
    Thank you for contributing to the Apple Support Communities.
    If Personal Hotspot doesn't seem to be enabled on your iPhone after updating to iOS 8, check for the option in both of these locations in Settings:
    Turn Personal Hotspot off and on: Tap Settings > Personal Hotspot or Settings > Cellular > Personal Hotspot.
    If the menu option can't be found, you may want to contact your carrier to ensure your account is set up correctly:
    Verify that your carrier supports Personal Hotspot for your device and that you have Personal Hotspot enabled on your cellular plan:
    iPhone: View a list of carriers that support Personal Hotspot on the iPhone.
    If the issue continues, try these troubleshooting steps next:
    Reset your network settings: Tap Settings > General > Reset > Reset Network Settings.
    If you still see the issue, restore the iPhone.
    You can find the information and steps above, as well as more troubleshooting advice, in these support articles:
    iOS: System requirements for Personal Hotspot - Apple Support
    iOS: Troubleshooting Personal Hotspot - Apple Support
    Best Regards,
    Jeremy

Maybe you are looking for

  • Select from sys.all_ind_columns works in sql*plus but not in stored proc

    I'm writing a query to find duplicate rows in a temporary table which has no unique index defined before I insert the data into the real table. I'm trying to query the sys.all_ind_columns view for the target table which belongs to a different schema:

  • Requirement part-2

    The processing sales orders within SAP ECC, the document creation triggers order fulfilment processes.  The fulfilment processes can be grouped in three main areas (delivery, shipment and billing).  The customer may place inquiries to obtain status o

  • How to convert mp4 to mp3 in itunes?

    Hi Can anyone help to convert mp4 audio files to mp3 for my car stereo? i have the latest itunes on windows. i only have a option to create new version to AAC.

  • DataSource 0FC_INVDOC_00 - Extraction

    Hi Experts, I am using 0FC_INVDOC_00 datasource for extracting invoicing data to BW. Data is not coming to BW . I refered this link- http://help.sap.com/erp2005_ehp_03/helpdata/EN/43/4d3eb20420321ae10000000a422035/frameset.htm. I am using this standa

  • cache-query-results question

    I have another post for general descriptor tag information but I do have a specific question. In a project I am looking at I see: <cache-usage> check cache by primary key </cache-usage> <cache-query-results>false</cache-query-results> <maintain-cache