VERSION 5.00
Begin VB.Form NtfnDlg 
   Caption         =   "Notifications (Visual Basic)"
   ClientHeight    =   5490
   ClientLeft      =   3900
   ClientTop       =   2730
   ClientWidth     =   8250
   ScaleHeight     =   5490
   ScaleWidth      =   8250
   Begin VB.CommandButton SendWMSMsg 
      Caption         =   "Send WMS Msg"
      Height          =   375
      Left            =   6120
      TabIndex        =   31
      Top             =   4920
      Width           =   1575
   End
   Begin VB.Frame UrlFrame 
      Caption         =   "Common Alert and Prefetch Settings"
      Height          =   2295
      Left            =   240
      TabIndex        =   18
      Top             =   120
      Width           =   5055
      Begin VB.TextBox UrlText 
         Height          =   285
         Left            =   720
         TabIndex        =   23
         Text            =   "http://updev.phone.com/dev/sdk.40/scripts/fetch.cgi?NEXT=MEETING"
         Top             =   840
         Width           =   4095
      End
      Begin VB.TextBox SubsText 
         Height          =   285
         Left            =   1320
         TabIndex        =   22
         Text            =   "000000000-00_devgate2.phone.com"
         Top             =   1320
         Width           =   3495
      End
      Begin VB.TextBox TtlText 
         Height          =   285
         Left            =   2160
         TabIndex        =   21
         Text            =   "0"
         Top             =   1920
         Width           =   735
      End
      Begin VB.TextBox HostText 
         Height          =   285
         Left            =   720
         TabIndex        =   20
         Text            =   "devgate2.phone.com"
         Top             =   360
         Width           =   4095
      End
      Begin VB.CheckBox UseSecure 
         Caption         =   "Use Certificate Info"
         Height          =   255
         Left            =   3120
         TabIndex        =   19
         Top             =   1920
         Width           =   1815
      End
      Begin VB.Label Label11 
         Caption         =   "(For WMS enter Phone #)"
         Height          =   225
         Left            =   240
         TabIndex        =   32
         Top             =   1605
         Width           =   1845
      End
      Begin VB.Label Label1 
         Caption         =   "URL:"
         Height          =   255
         Left            =   240
         TabIndex        =   27
         Top             =   840
         Width           =   375
      End
      Begin VB.Label Label4 
         Caption         =   "Subscriber ID:"
         Height          =   255
         Left            =   240
         TabIndex        =   26
         Top             =   1320
         Width           =   1455
      End
      Begin VB.Label Label5 
         Caption         =   "Time-to-live (in seconds):"
         Height          =   255
         Left            =   240
         TabIndex        =   25
         Top             =   1920
         Width           =   1815
      End
      Begin VB.Label Label6 
         Caption         =   "Host:"
         Height          =   255
         Left            =   240
         TabIndex        =   24
         Top             =   360
         Width           =   375
      End
   End
   Begin VB.ComboBox Combo1 
      Height          =   315
      Left            =   5640
      Style           =   2  'Dropdown List
      TabIndex        =   16
      Top             =   360
      Width           =   2535
   End
   Begin VB.CommandButton DeletePrefetch 
      Caption         =   "Delete Prefetch"
      Height          =   375
      Left            =   6120
      TabIndex        =   15
      Top             =   4200
      Width           =   1575
   End
   Begin VB.CommandButton DeleteAlert 
      Caption         =   "Delete Alert"
      Height          =   375
      Left            =   6120
      TabIndex        =   14
      Top             =   3720
      Width           =   1575
   End
   Begin VB.CommandButton PrefetchStatus 
      Caption         =   "Prefetch Status"
      Height          =   375
      Left            =   6120
      TabIndex        =   13
      Top             =   2880
      Width           =   1575
   End
   Begin VB.CommandButton AlertStatus 
      Caption         =   "Alert Status"
      Height          =   375
      Left            =   6120
      TabIndex        =   12
      Top             =   2400
      Width           =   1575
   End
   Begin VB.Frame Frame2 
      Caption         =   "Certificate and Password Information"
      Height          =   1335
      Left            =   240
      TabIndex        =   6
      Top             =   3960
      Width           =   5055
      Begin VB.CheckBox RequireSecure 
         Caption         =   "Require Certificate"
         Height          =   255
         Left            =   3120
         TabIndex        =   11
         Top             =   840
         Width           =   1695
      End
      Begin VB.TextBox PasswordText 
         Height          =   285
         Left            =   1320
         TabIndex        =   10
         Top             =   825
         Width           =   1575
      End
      Begin VB.TextBox CertFileText 
         Height          =   285
         Left            =   1320
         TabIndex        =   8
         Text            =   "c:\"
         Top             =   345
         Width           =   3495
      End
      Begin VB.Label Label8 
         Caption         =   "Password:"
         Height          =   255
         Left            =   240
         TabIndex        =   9
         Top             =   840
         Width           =   855
      End
      Begin VB.Label Label7 
         Caption         =   "Certificate File:"
         Height          =   255
         Left            =   240
         TabIndex        =   7
         Top             =   360
         Width           =   1095
      End
   End
   Begin VB.CommandButton SendPrefetch 
      Caption         =   "Send Prefetch"
      Height          =   375
      Left            =   6120
      TabIndex        =   5
      Top             =   1560
      Width           =   1575
   End
   Begin VB.CommandButton SendAlert 
      Caption         =   "Send Alert"
      Height          =   375
      Left            =   6120
      TabIndex        =   4
      Top             =   1080
      Width           =   1575
   End
   Begin VB.Frame Frame1 
      Caption         =   "Additional Alert Information"
      Height          =   1335
      Left            =   240
      TabIndex        =   0
      Top             =   2520
      Width           =   5055
      Begin VB.TextBox AlertCount 
         Height          =   285
         Left            =   3120
         TabIndex        =   30
         Text            =   "1"
         Top             =   840
         Width           =   375
      End
      Begin VB.ComboBox AlertUrgency 
         Height          =   315
         Left            =   1080
         TabIndex        =   28
         Text            =   "Urgency Types H-M-L-N"
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox AlertTitle 
         Height          =   285
         Left            =   1080
         TabIndex        =   2
         Text            =   "v4.0 Pushed Alert"
         Top             =   360
         Width           =   3735
      End
      Begin VB.Label Label10 
         Caption         =   "Count:"
         Height          =   255
         Left            =   2520
         TabIndex        =   29
         Top             =   870
         Width           =   495
      End
      Begin VB.Label Label3 
         Caption         =   "Urgency:"
         Height          =   255
         Left            =   240
         TabIndex        =   3
         Top             =   870
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "Alert Title:"
         Height          =   255
         Left            =   240
         TabIndex        =   1
         Top             =   375
         Width           =   735
      End
   End
   Begin VB.Label Label9 
      Caption         =   "Alert Title Charset:"
      Height          =   255
      Left            =   6240
      TabIndex        =   17
      Top             =   120
      Width           =   1335
   End
   Begin VB.Line Line6 
      BorderColor     =   &H80000011&
      BorderWidth     =   2
      X1              =   5760
      X2              =   8040
      Y1              =   840
      Y2              =   840
   End
   Begin VB.Line Line5 
      BorderColor     =   &H80000011&
      BorderWidth     =   2
      X1              =   5760
      X2              =   8040
      Y1              =   4800
      Y2              =   4800
   End
   Begin VB.Line Line4 
      BorderColor     =   &H80000011&
      BorderWidth     =   2
      X1              =   5760
      X2              =   8040
      Y1              =   3480
      Y2              =   3480
   End
   Begin VB.Line Line2 
      BorderColor     =   &H80000011&
      BorderWidth     =   2
      X1              =   5760
      X2              =   7920
      Y1              =   2160
      Y2              =   2160
   End
   Begin VB.Line Line1 
      BorderWidth     =   2
      X1              =   5520
      X2              =   5520
      Y1              =   120
      Y2              =   5400
   End
End
Attribute VB_Name = "NtfnDlg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

'********************************************************************
'*   Copyright 1999-2000 Phone.com, Inc.  All rights reserved.
'*
'*   Subject to the terms and conditions of the SDK License Agreement,
'*   Phone.com, Inc. hereby grants you the right to use the UP.SDK
'*   software and its related documentation.
'*
'*   The Phone.com name and logo and the family of terms carrying the "UP."
'*   prefix are trademarks of Phone.com, Inc. All other brands and product
'*   names may be trademarks of the respective companies with which they
'*   are associated.
'*
'********************************************************************
Private Sub DeleteSecureAlert()
    
    Dim result As Long
    Dim err As String

    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    'Set the fail-over state
    ntfn.NtfnRequireSecureConnection (NtfnDlg.RequireSecure)
    
    'Delete the Alert
    ntfn.NtfnDeleteAlert NtfnDlg.SubsText, NtfnDlg.UrlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Secure Alert Deleted sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Alert failed over to non-secure port sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
    End If

End Sub
Private Sub DeleteSecurePrefetch()
    
    Dim result As Long
    Dim err As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    'Set the fail-over state
    ntfn.NtfnRequireSecureConnection (NtfnDlg.RequireSecure)
    
    'Delete the Prefetch
    ntfn.NtfnDeletePrefetch NtfnDlg.SubsText, NtfnDlg.UrlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Secure Prefetch Deleted sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Prefetch failed over to non-secure port sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
    End If

End Sub
Private Sub DeleteNonSecureAlert()
    
    Dim result As Long
    Dim err As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Delete the Alert
    ntfn.NtfnDeleteAlert NtfnDlg.SubsText, NtfnDlg.UrlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Alert Deleted sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("NtfnDeleteAlert should NOT be using the secure protocol!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        MsgBox (ntfn.NtfnGetErrorDetail)
    End If

End Sub
Private Sub DeleteNonSecurePrefetch()
    
    Dim result As Long
    Dim err As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Delete the Prefetch
    ntfn.NtfnDeletePrefetch NtfnDlg.SubsText, NtfnDlg.UrlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Prefetch Deleted sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Prefetch should NOT be using secure protocol!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
    End If

End Sub
Private Sub SendSecurePrefetch()
    
    Dim result As Long
    Dim err As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    'Set the fail-over state
    ntfn.NtfnRequireSecureConnection (NtfnDlg.RequireSecure)
    
    'Send the Prefetch
    ntfn.NtfnPostPrefetch NtfnDlg.SubsText, NtfnDlg.UrlText, NtfnDlg.TtlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Secure Prefetch sent sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Prefetch failed over to non-secure port sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
    End If

End Sub
Private Sub SendSecureAlert()

    Dim result As Long
    Dim err As String
    Dim entity As String
    Dim AlertType As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    'Set the fail-over state
    ntfn.NtfnRequireSecureConnection (NtfnDlg.RequireSecure)
    
    'Set charest via text extracted from Charset combobox text.
     ntfn.NtfnSetCharset Mid(NtfnDlg.Combo1.Text, _
                     InStr(NtfnDlg.Combo1.Text, "(") + 1, _
                     Len(NtfnDlg.Combo1.Text) - InStr(NtfnDlg.Combo1.Text, "(") + 1)

    'build xml entity
    entity = "<?xml version=""1.0""?> " & vbNewLine & _
             "<!DOCTYPE ALERT " & vbNewLine & _
             "PUBLIC ""-//PHONE.COM//DTD ALERT 1.0//EN"" " & vbNewLine & _
             """http://www.phone.com/dtd/alert1.xml""> " & vbNewLine & _
             "<ALERT LABEL = """ + NtfnDlg.AlertTitle + """" + vbNewLine & _
             "COUNT = """ + AlertCount.Text + """" + vbNewLine & _
             "HREF = """" " & vbNewLine & _
             "URGENCY = """ + AlertUrgency.Text + """ />" & vbNewLine
    
    'send alert
    ntfn.NtfnPush NtfnDlg.SubsText, _
                    NtfnDlg.UrlText, _
                    "", _
                    NtfnDlg.TtlText, _
                    "application/vnd.uplanet.alert", _
                    entity
        
    'Test v4 alert result status
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Pushed 4.0 Alert sent sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Pushed 4.0... Something wrong here: NtfnGetProtocolType returned CNtfnProtoUpnotifyps!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: Pushed 4.0 NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        'check for "Unsupported Push Media Type", if so try v3 protocol PostAlert
        If result = 415 Then
            're-map v4 -> v3 alert urgency (backwards compatibility)
            If AlertUrgency.Text = "NONE" Then
                AlertType = "----"
            ElseIf AlertUrgency.Text = "LOW" Then
                AlertType = "--1-"
            ElseIf AlertUrgency.Text = "HIGH" Then
                AlertType = "-999"
            Else
                 AlertType = "D---"
            End If
            
            'send v3 PostAlert
            ntfn.NtfnPostAlert NtfnDlg.SubsText, _
                            NtfnDlg.UrlText, _
                            NtfnDlg.TtlText, _
                            AlertType, _
                            NtfnDlg.AlertTitle
            
            'check v3 protocol alert status
            result = ntfn.NtfnGetLastResult
            If result = CHTTPStatusNoContent Then
                If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
                    MsgBox ("Pushed 3.0 Alert sent sucessfully!")
                ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
                    MsgBox ("Pushed 3.0... Something wrong here: NtfnGetProtocolType returned CNtfnProtoUpnotifyps!")
                ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
                    MsgBox ("ERROR: Pushed 3.0 NtfnGetProtocolType returned CNtfnProtoNone.")
                End If
            Else
                err = ntfn.NtfnGetErrorDetail
                If err = Null Or err = "" Then
                    MsgBox ("No error detail. result = " + Str(result))
                Else
                    MsgBox (err)
                End If
            End If
        Else 'un-sup-push-media-type-415
            err = ntfn.NtfnGetErrorDetail
            If err = Null Or err = "" Then
                MsgBox ("No error detail. result = " + Str(result))
            Else
                MsgBox (err)
            End If
        End If 'check result
    End If
    
End Sub
Private Sub SendNonSecurePrefetch()
    
    Dim result As Long
    Dim err As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Send the Prefetch
    ntfn.NtfnPostPrefetch NtfnDlg.SubsText, _
                        NtfnDlg.UrlText, _
                        NtfnDlg.TtlText
    
    'Test the result code to see if the
    'notification was sucessful.
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        MsgBox ("Non-secure Prefetch sent sucessfully!")
    Else
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
    End If

End Sub
Private Sub SendNonSecureAlert()
    
    Dim result As Long
    Dim err As String
    Dim entity As String
    Dim AlertType As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
        
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set charest via text extracted from Charset combobox text.
     ntfn.NtfnSetCharset Mid(NtfnDlg.Combo1.Text, _
                     InStr(NtfnDlg.Combo1.Text, "(") + 1, _
                     Len(NtfnDlg.Combo1.Text) - InStr(NtfnDlg.Combo1.Text, "(") + 1)
    
    'build xml notification entity
    entity = "<?xml version=""1.0""?> " & vbNewLine & _
             "<!DOCTYPE ALERT " & vbNewLine & _
             "PUBLIC ""-//PHONE.COM//DTD ALERT 1.0//EN"" " & vbNewLine & _
             """http://www.phone.com.com/dtd/alert1.xml""> " & vbNewLine & _
             "<ALERT LABEL = """ + NtfnDlg.AlertTitle + """" + vbNewLine & _
             "COUNT = """ + AlertCount.Text + """" + vbNewLine & _
             "HREF = """" " & vbNewLine & _
             "URGENCY = """ + AlertUrgency.Text + """ />" & vbNewLine
             
    'Send notification push
    ntfn.NtfnPush NtfnDlg.SubsText, _
                    NtfnDlg.UrlText, _
                    "", _
                    NtfnDlg.TtlText, _
                    "application/vnd.uplanet.alert", _
                    entity
                
    'Test v4 protocol alert result code status
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("Pushed 4.0 Alert sent sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("Pushed 4.0... Something wrong here: NtfnGetProtocolType returned CNtfnProtoUpnotifyps!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: Pushed 4.0 NtfnGetProtocolType returned CNtfnProtoNone.")
        End If
    Else
        'check for "Unsupported Push Media Type", if so try v3 protocol PostAlert
        If result = 415 Then
            're-map v4 -> v3 alert urgency (backwards compatibility)
            If AlertUrgency.Text = "NONE" Then
                AlertType = "----"
            ElseIf AlertUrgency.Text = "LOW" Then
                AlertType = "--1-"
            ElseIf AlertUrgency.Text = "HIGH" Then
                AlertType = "-999"
            Else
                 AlertType = "D---"
            End If
            
            'send v3 PostAlert
            ntfn.NtfnPostAlert NtfnDlg.SubsText, _
                            NtfnDlg.UrlText, _
                            NtfnDlg.TtlText, _
                            AlertType, _
                            NtfnDlg.AlertTitle
            
            'check v3 protocol alert status
            result = ntfn.NtfnGetLastResult
            If result = CHTTPStatusNoContent Then
                If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
                    MsgBox ("Pushed 3.0 Alert sent sucessfully!")
                ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
                    MsgBox ("Pushed 3.0... Something wrong here: NtfnGetProtocolType returned CNtfnProtoUpnotifyps!")
                ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
                    MsgBox ("ERROR: Pushed 3.0 NtfnGetProtocolType returned CNtfnProtoNone.")
                End If
            Else
                err = ntfn.NtfnGetErrorDetail
                If err = Null Or err = "" Then
                    MsgBox ("No error detail. result = " + Str(result))
                Else
                    MsgBox (err)
                End If
            End If
        Else 'un-sup-push-media-type-415
            err = ntfn.NtfnGetErrorDetail
            If err = Null Or err = "" Then
                MsgBox ("No error detail. result = " + Str(result))
            Else
                MsgBox (err)
            End If
        End If 'check result
    End If
End Sub
Private Sub GetSecureAlertStatus()

    Dim result As Long
    Dim status As ENtfnStatus
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    status = ntfn.NtfnGetAlertStatus(NtfnDlg.SubsText, NtfnDlg.UrlText)
  
    If status = CNtfnStatusDelivered Then
        MsgBox "Alert Delivered"
    ElseIf status = CNtfnStatusExpired Then
        MsgBox "Alert Expired"
    ElseIf status = CNtfnStatusPending Then
        MsgBox "Alert Pending"
    ElseIf status = CNtfnStatusUndeliverable Then
        MsgBox "Alert Undeliverable"
    ElseIf status = CNtfnStatusNone Then
        MsgBox "NtfnGetAlertStatus returned CNtfnStatusNone!!!"
    End If
        
End Sub
Private Sub GetNonSecureAlertStatus()

    Dim result As Long
    Dim status As ENtfnStatus
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
        
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    status = ntfn.NtfnGetAlertStatus(NtfnDlg.SubsText, NtfnDlg.UrlText)
  
    If status = CNtfnStatusDelivered Then
        MsgBox "Alert Delivered"
    ElseIf status = CNtfnStatusExpired Then
        MsgBox "Alert Expired"
    ElseIf status = CNtfnStatusPending Then
        MsgBox "Alert Pending"
    ElseIf status = CNtfnStatusUndeliverable Then
        MsgBox "Alert Undeliverable"
    ElseIf status = CNtfnStatusNone Then
        MsgBox "NtfnGetAlertStatus returned CNtfnStatusNone!!!"
    End If
    
End Sub
Private Sub GetSecurePrefetchStatus()

    Dim result As Long
    Dim status As ENtfnStatus
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3SClient
    
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set the Certificate and Password
    ntfn.NtfnLoadCertAndKey NtfnDlg.CertFileText, NtfnDlg.PasswordText
    
    status = ntfn.NtfnGetPrefetchStatus(NtfnDlg.SubsText, NtfnDlg.UrlText)
  
    If status = CNtfnStatusDelivered Then
        MsgBox "Prefetch Delivered"
    ElseIf status = CNtfnStatusExpired Then
        MsgBox "Prefetch Expired"
    ElseIf status = CNtfnStatusPending Then
        MsgBox "Prefetch Pending"
    ElseIf status = CNtfnStatusUndeliverable Then
        MsgBox "Prefetch Undeliverable"
    ElseIf status = CNtfnStatusNone Then
        MsgBox "NtfnGetPrefetchStatus returned CNtfnStatusNone!!!"
    End If
        
End Sub
Private Sub GetNonSecurePrefetchStatus()

    Dim result As Long
    Dim status As ENtfnStatus
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
        
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    status = ntfn.NtfnGetPrefetchStatus(NtfnDlg.SubsText, NtfnDlg.UrlText)
  
    If status = CNtfnStatusDelivered Then
        MsgBox "Prefetch Delivered"
    ElseIf status = CNtfnStatusExpired Then
        MsgBox "Prefetch Expired"
    ElseIf status = CNtfnStatusPending Then
        MsgBox "Prefetch Pending"
    ElseIf status = CNtfnStatusUndeliverable Then
        MsgBox "Prefetch Undeliverable"
    ElseIf status = CNtfnStatusNone Then
        MsgBox "NtfnGetPrefetchStatus returned CNtfnStatusNone!!!"
    End If
    
End Sub
Private Sub AlertStatus_Click()

    If NtfnDlg.UseSecure Then
        GetSecureAlertStatus
    Else
        GetNonSecureAlertStatus
    End If
    
End Sub
Private Sub DeleteAlert_Click()
    
    If NtfnDlg.UseSecure Then
        DeleteSecureAlert
    Else
        DeleteNonSecureAlert
    End If
    
End Sub
Private Sub DeletePrefetch_Click()

    If NtfnDlg.UseSecure Then
        DeleteSecurePrefetch
    Else
        DeleteNonSecurePrefetch
    End If
    
End Sub
Private Sub Form_Load()

    
    
    'build charset combobox item list.
    Combo1.AddItem "United States (US-ASCII)"
    Combo1.AddItem "Western Europe (ISO-8859-1)"
    Combo1.AddItem "Central Europe (ISO-8859-2)"
    Combo1.AddItem "Greek (ISO-8859-7)"
    Combo1.AddItem "Hebrew (ISO-8859-8)"
    Combo1.AddItem "Turkish (ISO-8859-9)"
    Combo1.AddItem "Japanese (Shift_JIS)"
    Combo1.AddItem "Korean (KS_C_5601-198)"
    Combo1.AddItem "Simplified Chinese (GB2312-80)"
    Combo1.AddItem "Traditional Chinese (Big5)"
 
    'set charset combobox to default charset: US (US-ASCII)
    Combo1.Text = Combo1.List(0)
 
    'build urgency combobox
    AlertUrgency.AddItem "HIGH"
    AlertUrgency.AddItem "MEDIUM"
    AlertUrgency.AddItem "LOW"
    AlertUrgency.AddItem "NONE"
    
    'set combobox to default URGENCY type: MEDIUM
    AlertUrgency.Text = AlertUrgency.List(1)
    
End Sub
Private Sub PrefetchStatus_Click()
    
    If NtfnDlg.UseSecure Then
        GetSecurePrefetchStatus
    Else
        GetNonSecurePrefetchStatus
    End If

End Sub
Private Sub SendAlert_Click()

    If NtfnDlg.UseSecure Then
        SendSecureAlert
    Else
        SendNonSecureAlert
    End If

End Sub
Private Sub SendPrefetch_Click()

    If NtfnDlg.UseSecure Then
        SendSecurePrefetch
    Else
        SendNonSecurePrefetch
    End If

End Sub

Private Sub SendWMSMsg_Click()
    Dim result As Long
    Dim err As String
    Dim entity As String
    Dim AlertType As String
    
    'Create a new notification object instance
    Dim ntfn As New Ntfn3Client
        
    'Set the host from the dialog text
    ntfn.NtfnSetHost NtfnDlg.HostText
    
    'Set charest via text extracted from Charset combobox text.
    ntfn.NtfnSetCharset Mid(NtfnDlg.Combo1.Text, _
                     InStr(NtfnDlg.Combo1.Text, "(") + 1, _
                     Len(NtfnDlg.Combo1.Text) - InStr(NtfnDlg.Combo1.Text, "(") + 1)
    
    
    'use alert title for entity
    entity = NtfnDlg.AlertTitle & vbNewLine
             
    'Send notification push
    ntfn.NtfnPush "UPWMS-" & NtfnDlg.SubsText & "-_" & NtfnDlg.HostText, _
                    NtfnDlg.UrlText, _
                    "", _
                    NtfnDlg.TtlText, _
                    "text/plain", _
                    entity
                
    'Test result code status
    result = ntfn.NtfnGetLastResult
    If result = CHTTPStatusNoContent Then
        If ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyp Then
            MsgBox ("WMS message sent sucessfully!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoUpnotifyps Then
            MsgBox ("WMS message... Something wrong here: NtfnGetProtocolType returned CNtfnProtoUpnotifyps!")
        ElseIf ntfn.NtfnGetProtocolType = CNtfnProtoNone Then
            MsgBox ("ERROR: WMS message returned CNtfnProtoNone.")
        End If
    Else
        'check for "Unsupported Push Media Type"
        If result = 415 Then
            MsgBox ("ERROR: WMS Media Type of text/plain not accepted!")
        End If
        
        err = ntfn.NtfnGetErrorDetail
        If err = Null Or err = "" Then
            MsgBox ("No error detail. result = " + Str(result))
        Else
            MsgBox (err)
        End If
            
    End If
End Sub

