<commit_before>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.protocol.sip;

import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;

import javax.sip.*;
import java.util.*;

/**
 * A simple, straightforward implementation of a SIP Contact. Since
 * the SIP protocol is not a real one, we simply store all contact details
 * in class fields. You should know that when implementing a real protocol,
 * the contact implementation would rather encapsulate contact objects from
 * the protocol stack and group property values should be returned after
 * consulting the encapsulated object.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class ContactSipImpl
    implements Contact
{
    private static final Logger logger
        = Logger.getLogger(ContactSipImpl.class);

    /**
     * The id of the contact.
     */
    private String contactID = null;

    /**
     * The provider that created us.
     */
    private ProtocolProviderServiceSipImpl parentProvider = null;

    /**
     * The group that belong to.
     */
    private ContactGroupSipImpl parentGroup = null;

    /**
     * The presence status of the contact.
     */
    private PresenceStatus presenceStatus;

    /**
     * Determines whether this contact is persistent, i.e. member of the contact
     * list or whether it is here only temporarily.
     */
    private boolean isPersistent = true;

    /**
     * Determines whether the contact has been resolved (i.e. we have a
     * confirmation that it is still on the server contact list).
     */
    private boolean isResolved = false;
    
    /**
     * Determines whether this contact can be resolved or if he will be
     * never resolved (for example if he doesn't support SIMPLE)
     */
    private boolean isResolvable = true;
    
    /**
     * Stores the dialog used for receiving the contact status
     */
    private Dialog clientDialog = null;
    
    /**
     * Stores the dialog used for communicate our status to this contact
     */
    private Dialog serverDialog = null;
    
    /**
     * The task which will send a final NOTIFY when a timeout occur in the
     * subscription of this contact. If the contact isn't subscribed at us,
     * this will remain null.
     */
    private TimerTask timeoutTask = null;
    
    /**
     * The task which will refresh the subscription we've made with this
     * contact. If we didn't subscribe to this contact, it will remain null.
     */
    private TimerTask resfreshTask = null;
    
    /**
     * Creates an instance of a meta contact with the specified string used
     * as a name and identifier.
     *
     * @param id the identifier of this contact (also used as a name).
     * @param parentProvider the provider that created us.
     */
    public ContactSipImpl(
                String id,
                ProtocolProviderServiceSipImpl parentProvider)
    {
        this.contactID = id;
        this.parentProvider = parentProvider;
    }
<commit_msg>Initialize the presence status. This should fix the NullPointerException when we try to add a SIP contact.<commit_after>/*
 * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package net.java.sip.communicator.impl.protocol.sip;

import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;

import javax.sip.*;
import java.util.*;

/**
 * A simple, straightforward implementation of a SIP Contact. Since
 * the SIP protocol is not a real one, we simply store all contact details
 * in class fields. You should know that when implementing a real protocol,
 * the contact implementation would rather encapsulate contact objects from
 * the protocol stack and group property values should be returned after
 * consulting the encapsulated object.
 *
 * @author <NAME>
 * @author <NAME>
 */
public class ContactSipImpl
    implements Contact
{
    private static final Logger logger
        = Logger.getLogger(ContactSipImpl.class);

    /**
     * The id of the contact.
     */
    private String contactID = null;

    /**
     * The provider that created us.
     */
    private ProtocolProviderServiceSipImpl parentProvider = null;

    /**
     * The group that belong to.
     */
    private ContactGroupSipImpl parentGroup = null;

    /**
     * The presence status of the contact.
     */
    private PresenceStatus presenceStatus;

    /**
     * Determines whether this contact is persistent, i.e. member of the contact
     * list or whether it is here only temporarily.
     */
    private boolean isPersistent = true;

    /**
     * Determines whether the contact has been resolved (i.e. we have a
     * confirmation that it is still on the server contact list).
     */
    private boolean isResolved = false;
    
    /**
     * Determines whether this contact can be resolved or if he will be
     * never resolved (for example if he doesn't support SIMPLE)
     */
    private boolean isResolvable = true;
    
    /**
     * Stores the dialog used for receiving the contact status
     */
    private Dialog clientDialog = null;
    
    /**
     * Stores the dialog used for communicate our status to this contact
     */
    private Dialog serverDialog = null;
    
    /**
     * The task which will send a final NOTIFY when a timeout occur in the
     * subscription of this contact. If the contact isn't subscribed at us,
     * this will remain null.
     */
    private TimerTask timeoutTask = null;
    
    /**
     * The task which will refresh the subscription we've made with this
     * contact. If we didn't subscribe to this contact, it will remain null.
     */
    private TimerTask resfreshTask = null;
    
    /**
     * Creates an instance of a meta contact with the specified string used
     * as a name and identifier.
     *
     * @param id the identifier of this contact (also used as a name).
     * @param parentProvider the provider that created us.
     */
    public ContactSipImpl(
                String id,
                ProtocolProviderServiceSipImpl parentProvider)
    {
        this.contactID = id;
        this.parentProvider = parentProvider;
        
        this.presenceStatus = parentProvider.getSipStatusEnum()
            .getStatus(SipStatusEnum.UNKNOWN);
    }

{'fraction_non_alphanumeric': 0.0708697653014266, 'fraction_numerical': 0.0, 'mean_word_length': 2.531960996749729, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4940554', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1652, 'n_words': 715}