(sender="", recv="", broadcast=None, subject="", body="", reply=False)
| 706 | blackcur = len(blackcur)-1 |
| 707 | redraw(stdscr) |
| 708 | def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=False): |
| 709 | if sender == "": |
| 710 | return |
| 711 | d = Dialog(dialog="dialog") |
| 712 | set_background_title(d, "Send a message") |
| 713 | if recv == "": |
| 714 | r, t = d.inputbox("Recipient address (Cancel to load from the Address Book or leave blank to broadcast)", 10, 60) |
| 715 | if r != d.DIALOG_OK: |
| 716 | global menutab |
| 717 | menutab = 6 |
| 718 | return |
| 719 | recv = t |
| 720 | if broadcast == None and sender != recv: |
| 721 | r, t = d.radiolist("How to send the message?", |
| 722 | choices=[("1", "Send to one or more specific people", 1), |
| 723 | ("2", "Broadcast to everyone who is subscribed to your address", 0)]) |
| 724 | if r != d.DIALOG_OK: |
| 725 | return |
| 726 | broadcast = False |
| 727 | if t == "2": # Broadcast |
| 728 | broadcast = True |
| 729 | if subject == "" or reply: |
| 730 | r, t = d.inputbox("Message subject", width=60, init=subject) |
| 731 | if r != d.DIALOG_OK: |
| 732 | return |
| 733 | subject = t |
| 734 | if body == "" or reply: |
| 735 | r, t = d.inputbox("Message body", 10, 80, init=body) |
| 736 | if r != d.DIALOG_OK: |
| 737 | return |
| 738 | body = t |
| 739 | body = body.replace("\\n", "\n").replace("\\t", "\t") |
| 740 | |
| 741 | if not broadcast: |
| 742 | recvlist = [] |
| 743 | for i, item in enumerate(recv.replace(",", ";").split(";")): |
| 744 | recvlist.append(item.strip()) |
| 745 | list(set(recvlist)) # Remove exact duplicates |
| 746 | for addr in recvlist: |
| 747 | if addr != "": |
| 748 | status, version, stream, ripe = decodeAddress(addr) |
| 749 | if status != "success": |
| 750 | set_background_title(d, "Recipient address error") |
| 751 | err = "Could not decode" + addr + " : " + status + "\n\n" |
| 752 | if status == "missingbm": |
| 753 | err += "Bitmessage addresses should start with \"BM-\"." |
| 754 | elif status == "checksumfailed": |
| 755 | err += "The address was not typed or copied correctly." |
| 756 | elif status == "invalidcharacters": |
| 757 | err += "The address contains invalid characters." |
| 758 | elif status == "versiontoohigh": |
| 759 | err += "The address version is too high. Either you need to upgrade your Bitmessage software or your acquaintance is doing something clever." |
| 760 | elif status == "ripetooshort": |
| 761 | err += "Some data encoded in the address is too short. There might be something wrong with the software of your acquaintance." |
| 762 | elif status == "ripetoolong": |
| 763 | err += "Some data encoded in the address is too long. There might be something wrong with the software of your acquaintance." |
| 764 | elif status == "varintmalformed": |
| 765 | err += "Some data encoded in the address is malformed. There might be something wrong with the software of your acquaintance." |
no test coverage detected