示例#1
0
    def ReadPrivateLog(self):

        # Read log file
        config = self.frame.np.config.sections
        log = os.path.join(config["logging"]["privatelogsdir"],
                           fixpath(self.user.replace(os.sep, "-")) + ".log")

        try:
            lines = int(config["logging"]["readprivatelines"])
        except:
            lines = 15

        try:
            f = open(log, "r")
            d = f.read()
            f.close()
            s = d.split("\n")
            for l in s[-lines:-1]:
                AppendLine(self.ChatScroll,
                           l + "\n",
                           self.tag_hilite,
                           timestamp_format="",
                           username=self.user,
                           usertag=self.tag_hilite)
        except IOError, e:
            pass
示例#2
0
    def ShowUserInfo(self, descr, has_pic, pic, totalupl, queuesize,
                     slotsavail, uploadallowed):

        self.conn = None
        self._descr = descr
        self.image_pixbuf = None
        self.descr.get_buffer().set_text("")

        AppendLine(self.descr,
                   self.frame.np.decode(descr, self.encoding),
                   self.tag_local,
                   showstamp=False,
                   scroll=False)

        self.uploads.set_text(_("Total uploads allowed: %i") % totalupl)
        self.queuesize.set_text(_("Queue size: %i") % queuesize)

        if slotsavail:
            slots = _("Yes")
        else:
            slots = _("No")

        self.slotsavail.set_text(_("Slots free: %s") % slots)

        if uploadallowed == 0:
            allowed = _("No one")
        elif uploadallowed == 1:
            allowed = _("Everyone")
        elif uploadallowed == 2:
            allowed = _("Users in list")
        elif uploadallowed == 3:
            allowed = _("Trusted Users")
        else:
            allowed = _("unknown")

        self.AcceptUploads.set_text(_("%s") % allowed)

        if has_pic and pic is not None:
            try:
                import gc
                loader = gtk.gdk.PixbufLoader()
                loader.write(pic)
                loader.close()
                self.image_pixbuf = loader.get_pixbuf()
                self.image.set_from_pixbuf(self.image_pixbuf)
                del pic, loader
                gc.collect()
                self.actual_zoom = 0
                self.SavePicture.set_sensitive(True)
            except TypeError, e:
                name = tempfile.mktemp()
                f = open(name, "w")
                f.write(pic)
                f.close()
                self.image.set_from_file(name)
                os.remove(name)
            except Exception, e:
                self.image.set_from_pixbuf(None)
                self.SavePicture.set_sensitive(False)
示例#3
0
 def Login(self):
     timestamp_format = self.frame.np.config.sections["logging"][
         "private_timestamp"]
     AppendLine(self.ChatScroll,
                _("--- reconnected ---"),
                self.tag_hilite,
                timestamp_format=timestamp_format)
     self.ChangeColours()
示例#4
0
 def ConnClose(self):
     timestamp_format = self.frame.np.config.sections["logging"][
         "private_timestamp"]
     AppendLine(self.ChatScroll,
                _("--- disconnected ---"),
                self.tag_hilite,
                timestamp_format=timestamp_format)
     self.status = -1
     self.offlinemessage = 0
     self.ChangeColours()
示例#5
0
    def SendMessage(self, text, bytestring=False):

        user_text = self.frame.pluginhandler.OutgoingPrivateChatEvent(
            self.user, text)
        if user_text is None:
            return

        (u, text) = user_text

        my_username = self.frame.np.config.sections["server"]["login"]

        if text[:4] == "/me ":
            line = "* %s %s" % (my_username, text[4:])
            usertag = tag = self.tag_me
        else:

            if text == CTCP_VERSION:
                line = "CTCP VERSION"
            else:
                line = text

            tag = self.tag_local
            usertag = self.tag_my_username
            line = "[%s] %s" % (my_username, line)

        timestamp_format = self.frame.np.config.sections["logging"][
            "private_timestamp"]
        AppendLine(self.ChatScroll,
                   line,
                   tag,
                   timestamp_format=timestamp_format,
                   username=my_username,
                   usertag=usertag)

        if self.Log.get_active():
            WriteLog(
                self.frame.np.config.sections["logging"]["privatelogsdir"],
                self.user, line)

        if bytestring:
            payload = text
        else:
            payload = ToBeEncoded(self.frame.AutoReplace(text), self.encoding)

        if self.PeerPrivateMessages.get_active():
            # not in the soulseek protocol
            self.frame.np.ProcessRequestToPeer(
                self.user, slskmessages.PMessageUser(None, my_username,
                                                     payload))
        else:
            self.frame.np.queue.put(
                slskmessages.MessageUser(self.user, payload))
示例#6
0
    def __init__(self, parent, nicotine):
        self.nicotine = nicotine
        GenericAboutDialog.__init__(self, parent, _("License"), self.nicotine)
        self.set_resizable(True)
        self.resize(550, 450)
        self.ScrolledWindow = gtk.ScrolledWindow()
        self.ScrolledWindow.set_shadow_type(gtk.SHADOW_IN)
        self.ScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
                                       gtk.POLICY_AUTOMATIC)
        self.ScrolledWindow.show()

        self.TextView = gtk.TextView()
        self.TextView.set_cursor_visible(False)
        self.TextView.set_editable(False)
        self.TextView.set_left_margin(3)
        self.TextView.show()
        self.ScrolledWindow.add(self.TextView)

        text = """GNU General Public License version 3 notice

Copyright (C) 2007 daelstorm. All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see < http://www.gnu.org/licenses/ >."""

        AppendLine(self.TextView, text, None, None, showstamp=False)
        self.vbox.pack_start(self.ScrolledWindow)
        self.show_all()
示例#7
0
    def __init__(self, parent, nicotine):

        self.nicotine = nicotine

        gtk.Dialog.__init__(self, _("About Nicotine+"), parent, gtk.DIALOG_MODAL)

        self.set_resizable(True)
        self.set_position(gtk.WIN_POS_CENTER)
        self.vbox.set_spacing(10)
        self.set_border_width(5)

        img = gtk.Image()
        img.set_from_pixbuf(self.nicotine.images["n"])

        ScrolledWindow = gtk.ScrolledWindow()
        ScrolledWindow.set_shadow_type(gtk.SHADOW_IN)
        ScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        ScrolledWindow.show()
        ScrolledWindow.set_size_request(400, 250)

        TextView = gtk.TextView()
        TextView.set_wrap_mode(gtk.WRAP_WORD)
        TextView.set_cursor_visible(False)
        TextView.set_editable(False)
        TextView.show()
        TextView.set_left_margin(3)
        ScrolledWindow.add(TextView)

        text = _("""Nicotine+ %s
Website:
https://www.nicotine-plus.org
Bug Tracker & Source Code:
https://github.com/Nicotine-Plus/nicotine-plus

Soulseek: http://www.slsknet.org

Based on code from Nicotine and PySoulSeek""") % version

        AppendLine(TextView, text, None, None, showstamp=False)
        vbox = gtk.VBox()
        vbox.pack_start(img, False, True)
        hbox = gtk.HBox()
        hbox.set_spacing(10)
        hbox.pack_start(vbox, False, True)
        hbox.pack_start(ScrolledWindow, True, True)

        self.expander = gtk.Expander(_("Dependencies"))
        self.expander.show()

        pythonversion = '.'.join(map(str, sys.version_info[:3]))

        self.vbox2 = gtk.VBox()
        self.vbox2.set_spacing(5)
        self.vbox2.set_border_width(5)
        self.expander.add(self.vbox2)

        hboxpython = gtk.HBox(5)
        hboxpython.show()
        python = gtk.Label("Python:")
        python.set_alignment(0, 0.5)
        python.show()

        VersionPython = gtk.Label(pythonversion)
        VersionPython.set_alignment(0, 0.5)
        VersionPython.show()

        hboxpython.pack_start(python, True, True)
        hboxpython.pack_start(VersionPython, True, True)

        hboxgtk = gtk.HBox(5)
        hboxgtk.show()

        gtkversion = '.'.join(map(str, gtk.gtk_version[:3]))

        VersionGTK = gtk.Label(gtkversion)

        gtkplus = gtk.Label("GTK+:")
        gtkplus.set_alignment(0, 0.5)
        gtkplus.show()

        VersionGTK.set_alignment(0, 0.5)
        VersionGTK.show()

        hboxgtk.pack_start(gtkplus, True, True)
        hboxgtk.pack_start(VersionGTK, True, True)

        hboxpygtk = gtk.HBox(5)
        hboxpygtk.show()

        pygtkversion = '.'.join(map(str, gtk.pygtk_version[:3]))

        VersionPyGTK = gtk.Label(pygtkversion)

        pygtkplus = gtk.Label("PyGTK+:")
        pygtkplus.set_alignment(0, 0.5)
        pygtkplus.show()

        VersionPyGTK.set_alignment(0, 0.5)
        VersionPyGTK.show()

        hboxpygtk.pack_start(pygtkplus, True, True)
        hboxpygtk.pack_start(VersionPyGTK, True, True)

        self.vbox2.pack_start(hboxpython, True, True)
        self.vbox2.pack_start(hboxgtk, True, True)
        self.vbox2.pack_start(hboxpygtk, True, True)

        self.vbox.pack_start(hbox, True, True)
        self.vbox.pack_start(self.expander, True, True)

        self.LicenseButton = self.nicotine.CreateIconButton(
            gtk.STOCK_ABOUT,
            "stock",
            self.license, _("License")
        )

        self.action_area.pack_start(self.LicenseButton)

        self.CreditsButton = self.nicotine.CreateIconButton(
            gtk.STOCK_ABOUT,
            "stock",
            self.credits,
            _("Credits")
        )

        self.action_area.pack_start(self.CreditsButton)

        self.CloseButton = self.nicotine.CreateIconButton(
            gtk.STOCK_CLOSE,
            "stock",
            self.click,
            _("Close")
        )

        self.CloseButton.set_flags(gtk.CAN_DEFAULT)
        self.action_area.pack_start(self.CloseButton)

        self.show_all()
示例#8
0
    def __init__(self, parent, nicotine):
        self.nicotine = nicotine
        GenericAboutDialog.__init__(self, parent, _("Credits"), self.nicotine)
        self.set_resizable(True)
        self.resize(450, 300)
        self.notebook = gtk.Notebook()
        self.notebook.show()
        self.DevScrolledWindow = gtk.ScrolledWindow()
        self.DevScrolledWindow.set_shadow_type(gtk.SHADOW_IN)
        self.DevScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
                                          gtk.POLICY_AUTOMATIC)
        self.DevScrolledWindow.show()

        self.DevTextView = gtk.TextView()
        self.DevTextView.set_wrap_mode(gtk.WRAP_WORD)
        self.DevTextView.set_cursor_visible(False)
        self.DevTextView.set_editable(False)
        self.DevTextView.show()
        self.DevTextView.set_left_margin(3)
        self.DevScrolledWindow.add(self.DevTextView)

        text = """
# Nicotine+ MAINTAINERS

### Active

Michael Labouebe (aka gfarmerfr)
- Developer
- [gfarmerfr(at)free(dot)fr]

Mutnick
- Created Nicotine+ GitHub Organization
- Developer
- [muhing(at)yahoo(dot)com]

eLvErDe
- Provides Nicotine+ Website
- Migrated source code from SVN to Github
- Developer (retired ?)

Kip Warner
- Debianization
- [kip(at)thevertigo(dot)com]

### Retired

daelstorm
- Developer
- [daelstorm(at)gmail(dot)com]

gallows (aka 'burp O')
- Developer, Packager
- [g4ll0ws(at)gmail(dot)com]
- Submitted Slack.Build file

QuinoX
- Developer

hedonist (formerly known as alexbk)
- OS X nicotine.app maintainer / developer
- [ak(at)sensi(dot)org]
- Author of original pyslsk, which is used for nicotine core

lee8oi
- Bash Commander
- [winslaya(at)gmail(dot)com]
- New and updated /alias

INMCM
- Nicotine+ topic maintainer on ubuntuforums.org
- http://ubuntuforums.org/showthread.php?t=196835

suser-guru
- Suse Linux packager
- https://dev-loki.blogspot.fr/
- Nicotine+ RPM's for Suse 9.1, 9.2, 9.3, 10.0, 10.1

osiris
- handy-man, documentation, some GNU/Linux packaging, Nicotine+ on win32
- Author of Nicotine+ Guide
- [osiris.contact(at)gmail(dot)com]

# Nicotine MAINTAINERS

### Retired

Hyriand
- Founder
- [hyriand(at)thegraveyard(dot)org]

osiris
- handy-man
- [osiris.contact(at)gmail(dot)com]

SmackleFunky
- Beta tester

Wretched
- Beta tester
- Bringer of great ideas

(va)\*10^3
- Beta tester
- Designer of the old nicotine homepage and artwork (logos)

sierracat
- MacOSX tester
- Developed soulseeX

Gustavo
- [gjc(at)inescporto(dot)pt]
- Made the exception dialog

SeeSchloss
- Developer
- Made 1.0.8 win32 installer
- Created Soulfind http://seeschloss.org/soulfind.html,
  opensource Soulseek Server written in D

vasi
- Mac developer
- [[email protected]]
- Packaged nicotine on OSX PowerPc

Country flags provided by http://flags.blogpotato.de/,
distributed under a CC BY-SA 3.0 Unported license."""

        AppendLine(self.DevTextView, text, None, None, showstamp=False)

        developersLabel = gtk.Label(_("Developers"))
        developersLabel.show()
        self.notebook.append_page(self.DevScrolledWindow, developersLabel)

        self.TransScrolledWindow = gtk.ScrolledWindow()
        self.TransScrolledWindow.set_shadow_type(gtk.SHADOW_IN)
        self.TransScrolledWindow.set_policy(gtk.POLICY_AUTOMATIC,
                                            gtk.POLICY_AUTOMATIC)
        self.TransScrolledWindow.show()

        self.TransTextView = gtk.TextView()
        self.TransTextView.set_wrap_mode(gtk.WRAP_WORD)
        self.TransTextView.set_cursor_visible(False)
        self.TransTextView.set_editable(False)
        self.TransTextView.set_left_margin(3)
        self.TransTextView.show()
        self.TransScrolledWindow.add(self.TransTextView)

        text = """
Dutch
 * nince78 (2007)
 * hyriand

German
 * Meokater (2007)
 * (._.) (2007)
 * lippel (2004)
 * hyriand (2003)

Spanish
 * Silvio Orta (2007)
 * Dreslo

French
 * Michael Labouebe (2016-2017) <*****@*****.**>
 * ManWell (2007)
 * ><((((*> (2007-2009)
 * flashfr
 * systr

Italian
 * Nicola (2007) <*****@*****.**>
 * dbazza

Polish
 * Amun-Ra (2007)
 * thine (2007)
 * owczi

Swedish
 * alimony <*****@*****.**>

Hungarian
 * djbaloo <*****@*****.**>

Slovak
 * Josef Riha (2006) <*****@*****.**>

Portuguese Brazilian
 * Suicide|Solution (2006) <*****@*****.**>

Lithuanian
 * Žygimantas Beručka (2006) <*****@*****.**>

Finnish
 * Kalevi <*****@*****.**>

Euskara
 * The Librezale.org Team <*****@*****.**>"""

        AppendLine(self.TransTextView, text, None, None, showstamp=False)

        translatorsLabel = gtk.Label(_("Translators"))
        translatorsLabel.show()
        self.notebook.append_page(self.TransScrolledWindow, translatorsLabel)
        self.vbox.pack_start(self.notebook)
示例#9
0
    def OnEnter(self, widget):

        bytes = widget.get_text()

        try:
            text = unicode(bytes, "UTF-8")
        except UnicodeDecodeError:
            log.addwarning(
                _("We have a problem, PyGTK get_text does not seem to return UTF-8. Please file a bug report. Bytes: %s"
                  ) % (repr(bytes)))
            text = unicode(bytes, "UTF-8", "replace")

        if not text:
            widget.set_text("")
            return

        if is_alias(self.frame.np.config.aliases, text):
            import thread
            thread.start_new_thread(self.threadAlias, (text, ))
            widget.set_text("")
            return

        s = text.split(" ", 1)
        cmd = s[0]
        if len(s) == 2 and s[1]:
            realargs = args = s[1]
        else:
            args = self.user
            realargs = ""

        if cmd in ("/alias", "/al"):

            AppendLine(self.ChatScroll,
                       self.frame.np.config.AddAlias(realargs), None, "")
            if self.frame.np.config.sections["words"]["aliases"]:
                self.frame.chatrooms.roomsctrl.UpdateCompletions()
                self.frame.privatechats.UpdateCompletions()

        elif cmd in ("/unalias", "/un"):

            AppendLine(self.ChatScroll, self.frame.np.config.Unalias(realargs),
                       None, "")
            if self.frame.np.config.sections["words"]["aliases"]:
                self.frame.chatrooms.roomsctrl.UpdateCompletions()
                self.frame.privatechats.UpdateCompletions()

        elif cmd in ["/join", "/j"]:
            self.frame.np.queue.put(slskmessages.JoinRoom(args))

        elif cmd in ["/w", "/whois", "/info"]:
            if args:
                self.frame.LocalUserInfoRequest(args)
                self.frame.OnUserInfo(None)

        elif cmd in ["/b", "/browse"]:
            if args:
                self.frame.BrowseUser(args)
                self.frame.OnUserBrowse(None)

        elif cmd == "/ip":
            if args:
                user = args
                if user not in self.frame.np.ip_requested:
                    self.frame.np.ip_requested.append(user)
                self.frame.np.queue.put(slskmessages.GetPeerAddress(user))

        elif cmd == "/pm":
            if realargs:
                self.frame.privatechats.SendMessage(realargs, None, 1)

        elif cmd in ["/m", "/msg"]:
            if realargs:
                s = realargs.split(" ", 1)
                user = s[0]
                if len(s) == 2:
                    msg = s[1]
                else:
                    msg = None

                self.frame.privatechats.SendMessage(user, msg)

        elif cmd in ["/s", "/search"]:
            if realargs:
                self.frame.Searches.DoSearch(realargs, 0)
                self.frame.OnSearch(None)

        elif cmd in ["/us", "/usearch"]:
            if realargs:
                self.frame.Searches.DoSearch(realargs, 3, [self.user])
                self.frame.OnSearch(None)

        elif cmd in ["/rs", "/rsearch"]:
            if realargs:
                self.frame.Searches.DoSearch(realargs, 1)
                self.frame.OnSearch(None)

        elif cmd in ["/bs", "/bsearch"]:
            if realargs:
                self.frame.Searches.DoSearch(realargs, 2)
                self.frame.OnSearch(None)

        elif cmd in ["/ad", "/add", "/buddy"]:
            if args:
                self.frame.userlist.AddToList(args)

        elif cmd in ["/rem", "/unbuddy"]:
            if args:
                self.frame.userlist.RemoveFromList(args)

        elif cmd == "/ban":
            if args:
                self.frame.BanUser(args)

        elif cmd == "/ignore":
            if args:
                self.frame.IgnoreUser(args)

        elif cmd == "/ignoreip":
            if args:
                self.frame.IgnoreIP(args)

        elif cmd == "/unban":
            if args:
                self.frame.UnbanUser(args)

        elif cmd == "/unignore":
            if args:
                self.frame.UnignoreUser(args)

        elif cmd == "/ctcpversion":
            if args:
                self.frame.privatechats.SendMessage(args,
                                                    CTCP_VERSION,
                                                    1,
                                                    bytestring=True)

        elif cmd in ["/clear", "/cl"]:
            self.ChatScroll.get_buffer().set_text("")

        elif cmd in ["/a", "/away"]:
            self.frame.OnAway(None)

        elif cmd in ["/q", "/quit", "/exit"]:
            self.frame.OnExit(None)
            return

        elif cmd in ["/c", "/close"]:
            self.OnClose(None)

        elif cmd == "/now":
            self.NowPlayingThread()

        elif cmd == "/detach":
            self.Detach()

        elif cmd == "/attach":
            self.Attach()

        elif cmd == "/rescan":
            self.frame.OnRescan()

        elif cmd[:
                 1] == "/" and self.frame.pluginhandler.TriggerPrivateCommandEvent(
                     self.user, cmd[1:], args):
            pass

        elif cmd and cmd[:1] == "/" and cmd != "/me" and cmd[:2] != "//":
            self.frame.logMessage(_("Command %s is not recognized") % text)
            return

        else:

            if text[:2] == "//":
                text = text[1:]

            if self.chats.connected:
                self.SendMessage(text)
                widget.set_text("")

            return

        widget.set_text("")
示例#10
0
    def ShowMessage(self, text, status=None, timestamp=None):

        if text[:4] == "/me ":
            line = "* %s %s" % (self.user, self.frame.CensorChat(text[4:]))
            speech = line[2:]
            tag = self.tag_me
        else:
            line = "[%s] %s" % (self.user, self.frame.CensorChat(text))
            speech = self.frame.CensorChat(text)
            tag = self.tag_remote

        timestamp_format = self.frame.np.config.sections["logging"][
            "private_timestamp"]
        if status and not self.offlinemessage:
            AppendLine(
                self.ChatScroll,
                _("* Message(s) sent while you were offline. Timestamps are reported by the server and can be off."
                  ),
                self.tag_hilite,
                timestamp_format=timestamp_format)
            self.offlinemessage = 1

        if not status and self.offlinemessage:
            self.offlinemessage = False

        if status:
            # The timestamps from the server are off by a lot, so we'll only use them when this is an offline message
            # Also, they are in UTC so we need to correct them
            if daylight:
                timestamp -= (3600 * daylight)
            else:
                timestamp += altzone

            AppendLine(self.ChatScroll,
                       line,
                       self.tag_hilite,
                       timestamp=timestamp,
                       timestamp_format=timestamp_format,
                       username=self.user,
                       usertag=self.tag_username)
        else:
            AppendLine(self.ChatScroll,
                       line,
                       tag,
                       timestamp_format=timestamp_format,
                       username=self.user,
                       usertag=self.tag_username)

        if self.Log.get_active():
            WriteLog(
                self.frame.np.config.sections["logging"]["privatelogsdir"],
                self.user, line)

        autoreply = self.frame.np.config.sections["server"]["autoreply"]
        if self.frame.away and not self.autoreplied and autoreply:
            self.SendMessage(u"[Auto-Message] %s" % autoreply)
            self.autoreplied = 1

        self.frame.Notifications.new_tts(
            self.frame.np.config.sections["ui"]["speechprivate"] % {
                "user": self.frame.Notifications.tts_clean(self.user),
                "message": self.frame.Notifications.tts_clean(speech)
            })