⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 voicemail.java

📁 开源项目openfire的完整源程序
💻 JAVA
字号:
/**
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2007 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Lesser Public License (LGPL),
 * a copy of which is included in this distribution.
 */

package net.java.sipmack.softphone;

import net.java.sipmack.sip.event.MessageEvent;
import org.jivesoftware.resource.SparkRes;

import javax.sip.message.Request;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

public class VoiceMail {

    Request request = null;

    private String read = "";

    private String unread = "";

    public VoiceMail(MessageEvent evt) {

        String body = evt.getBody();

        String match = "Voice-Message:";

        int a = body.indexOf(match);
        if (a > 0) {

            a += match.length();
            int b = body.indexOf("\n", a);

            String msgs[] = body.substring(a, b - 1).trim().split("\\(")[0]
                    .split("/");

            unread = msgs[0].trim();
            read = msgs[1].trim();

        }

    }

    public String getRead() {
        return read;
    }

    public String getUnread() {
        return unread;
    }

    public JPanel getToaster() {

        JPanel toaster = new JPanel();

        toaster.setLayout(new GridBagLayout());
        toaster.setBackground(Color.white);

        JLabel newVoiceMail = new JLabel();
        JLabel oldVoiceMail = new JLabel();

        newVoiceMail.setFont(new Font("Dialog", Font.BOLD, 15));
        newVoiceMail.setHorizontalAlignment(JLabel.CENTER);
        newVoiceMail.setText("New: " + this.getUnread());

        oldVoiceMail.setFont(new Font("Dialog", Font.PLAIN, 15));
        oldVoiceMail.setHorizontalAlignment(JLabel.CENTER);
        oldVoiceMail.setText("Old: " + this.getRead());

        final JLabel phoneImage = new JLabel(SparkRes
                .getImageIcon(SparkRes.MAIL_IMAGE_32x32));
        phoneImage.setHorizontalAlignment(JLabel.CENTER);
        phoneImage.setVerticalTextPosition(JLabel.BOTTOM);
        phoneImage.setHorizontalTextPosition(JLabel.CENTER);
        phoneImage.setText("Voice Mails");
        phoneImage.setFont(new Font("Dialog", Font.BOLD, 16));

        toaster.add(phoneImage, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
                GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
                new Insets(5, 10, 0, 10), 0, 0));
        toaster.add(newVoiceMail, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                new Insets(2, 0, 0, 0), 0, 0));
        toaster.add(oldVoiceMail, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
                GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
                new Insets(2, 0, 10, 0), 0, 0));

        return toaster;

    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -